From 097ae84c0c9290703f751abb96799fa77bea730b Mon Sep 17 00:00:00 2001 From: Panos Koutsovasilis Date: Fri, 22 Mar 2024 00:00:05 +0200 Subject: [PATCH 001/154] feat: [pod autosharding] transition from labelselector to fieldselector --- pkg/metricshandler/metrics_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index 911d24b161..11b054bf81 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -111,12 +111,12 @@ func (m *MetricsHandler) Run(ctx context.Context) error { } statefulSetName := ss.Name - labelSelectorOptions := func(o *metav1.ListOptions) { - o.LabelSelector = fields.SelectorFromSet(ss.Labels).String() + fieldSelectorOptions := func(o *metav1.ListOptions) { + o.FieldSelector = fields.OneTermEqualSelector("metadata.name", statefulSetName).String() } i := cache.NewSharedIndexInformer( - cache.NewFilteredListWatchFromClient(m.kubeClient.AppsV1().RESTClient(), "statefulsets", m.opts.Namespace, labelSelectorOptions), + cache.NewFilteredListWatchFromClient(m.kubeClient.AppsV1().RESTClient(), "statefulsets", m.opts.Namespace, fieldSelectorOptions), &appsv1.StatefulSet{}, 0, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, ) i.AddEventHandler(cache.ResourceEventHandlerFuncs{ From a40944b47bcfd3635bebf489bb1cfaa8b4e069a6 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Mon, 15 Apr 2024 17:26:55 +0100 Subject: [PATCH 002/154] feat: add kube_persistentvolume_volume_mode metric Signed-off-by: Ricardo Lopes --- .../storage/persistentvolume-metrics.md | 1 + internal/store/persistentvolume.go | 24 ++++++++++++++ internal/store/persistentvolume_test.go | 33 +++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/docs/metrics/storage/persistentvolume-metrics.md b/docs/metrics/storage/persistentvolume-metrics.md index d4cdd569cf..3714ed49dd 100644 --- a/docs/metrics/storage/persistentvolume-metrics.md +++ b/docs/metrics/storage/persistentvolume-metrics.md @@ -11,6 +11,7 @@ | kube_persistentvolume_created | Gauge | Unix creation timestamp | seconds | `persistentvolume`=<persistentvolume-name>
| EXPERIMENTAL | | kube_persistentvolume_deletion_timestamp | Gauge | Unix deletion timestamp | seconds | `persistentvolume`=<persistentvolume-name>
| EXPERIMENTAL | | kube_persistentvolume_csi_attributes | Gauge | CSI attributes of the Persistent Volume, disabled by default, manage with [--metric-opt-in-list](../../developer/cli-arguments.md)) | | `persistentvolume`=<persistentvolume-name>
`csi_mounter`=<csi-mounter>
`csi_map_options`=<csi-map-options> | EXPERIMENTAL | +| kube_persistentvolume_volume_mode | Gauge | | | `persistentvolume`=<persistentvolume-name>
`volumemode`=<volumemode> | EXPERIMENTAL | ## Useful metrics queries diff --git a/internal/store/persistentvolume.go b/internal/store/persistentvolume.go index 53f21bdd6e..179c02c89b 100644 --- a/internal/store/persistentvolume.go +++ b/internal/store/persistentvolume.go @@ -392,6 +392,30 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri } }), ), + *generator.NewFamilyGeneratorWithStability( + "kube_persistentvolume_volume_mode", + "Volume Mode information for PersistentVolume.", + metric.Gauge, + basemetrics.ALPHA, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + volumeMode := "" + if p.Spec.VolumeMode != nil { + volumeMode = string(*p.Spec.VolumeMode) + } else { + volumeMode = string("Filesystem") // Filesystem is the default mode used when volumeMode parameter is omitted. + } + + return &metric.Family{ + Metrics: []*metric.Metric{ + { + LabelKeys: []string{"volumemode"}, + LabelValues: []string{volumeMode}, + Value: 1, + }, + }} + }), + ), } } diff --git a/internal/store/persistentvolume_test.go b/internal/store/persistentvolume_test.go index d704686fbe..6806cf0939 100644 --- a/internal/store/persistentvolume_test.go +++ b/internal/store/persistentvolume_test.go @@ -30,6 +30,7 @@ import ( func TestPersistentVolumeStore(t *testing.T) { iscsiInitiatorName := "iqn.my.test.initiator:112233" + volumeMode := v1.PersistentVolumeBlock cases := []generateMetricsTestCase{ // Verify phase enumerations. { @@ -743,6 +744,38 @@ func TestPersistentVolumeStore(t *testing.T) { `, MetricNames: []string{"kube_persistentvolume_csi_attributes"}, }, + { + Obj: &v1.PersistentVolume{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-default-volumemode", + }, + Spec: v1.PersistentVolumeSpec{ + VolumeMode: nil, + }, + }, + Want: ` + # HELP kube_persistentvolume_volume_mode Volume Mode information for PersistentVolume. + # TYPE kube_persistentvolume_volume_mode gauge + kube_persistentvolume_volume_mode{persistentvolume="test-default-volumemode",volumemode="Filesystem"} 1 + `, + MetricNames: []string{"kube_persistentvolume_volume_mode"}, + }, + { + Obj: &v1.PersistentVolume{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-block-volumemode", + }, + Spec: v1.PersistentVolumeSpec{ + VolumeMode: &volumeMode, + }, + }, + Want: ` + # HELP kube_persistentvolume_volume_mode Volume Mode information for PersistentVolume. + # TYPE kube_persistentvolume_volume_mode gauge + kube_persistentvolume_volume_mode{persistentvolume="test-block-volumemode",volumemode="Block"} 1 + `, + MetricNames: []string{"kube_persistentvolume_volume_mode"}, + }, } for i, c := range cases { c.Func = generator.ComposeMetricGenFuncs(persistentVolumeMetricFamilies(c.AllowAnnotationsList, c.AllowLabelsList)) From 610918ea240741e6d61829303d6bc90f9b6e4e95 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Mon, 15 Apr 2024 17:32:12 +0100 Subject: [PATCH 003/154] fixup! feat: add kube_persistentvolume_volume_mode metric Signed-off-by: Ricardo Lopes --- docs/metrics/storage/persistentvolume-metrics.md | 2 +- internal/store/persistentvolume.go | 2 +- internal/store/persistentvolume_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/metrics/storage/persistentvolume-metrics.md b/docs/metrics/storage/persistentvolume-metrics.md index 3714ed49dd..d6e9b08ddf 100644 --- a/docs/metrics/storage/persistentvolume-metrics.md +++ b/docs/metrics/storage/persistentvolume-metrics.md @@ -11,7 +11,7 @@ | kube_persistentvolume_created | Gauge | Unix creation timestamp | seconds | `persistentvolume`=<persistentvolume-name>
| EXPERIMENTAL | | kube_persistentvolume_deletion_timestamp | Gauge | Unix deletion timestamp | seconds | `persistentvolume`=<persistentvolume-name>
| EXPERIMENTAL | | kube_persistentvolume_csi_attributes | Gauge | CSI attributes of the Persistent Volume, disabled by default, manage with [--metric-opt-in-list](../../developer/cli-arguments.md)) | | `persistentvolume`=<persistentvolume-name>
`csi_mounter`=<csi-mounter>
`csi_map_options`=<csi-map-options> | EXPERIMENTAL | -| kube_persistentvolume_volume_mode | Gauge | | | `persistentvolume`=<persistentvolume-name>
`volumemode`=<volumemode> | EXPERIMENTAL | +| kube_persistentvolume_volume_mode | Gauge | Volume Mode information for the PersistentVolume. | | `persistentvolume`=<persistentvolume-name>
`volumemode`=<volumemode> | EXPERIMENTAL | ## Useful metrics queries diff --git a/internal/store/persistentvolume.go b/internal/store/persistentvolume.go index 179c02c89b..1f9e647748 100644 --- a/internal/store/persistentvolume.go +++ b/internal/store/persistentvolume.go @@ -394,7 +394,7 @@ func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []stri ), *generator.NewFamilyGeneratorWithStability( "kube_persistentvolume_volume_mode", - "Volume Mode information for PersistentVolume.", + "Volume Mode information for the PersistentVolume.", metric.Gauge, basemetrics.ALPHA, "", diff --git a/internal/store/persistentvolume_test.go b/internal/store/persistentvolume_test.go index 6806cf0939..e4e6847ca2 100644 --- a/internal/store/persistentvolume_test.go +++ b/internal/store/persistentvolume_test.go @@ -754,7 +754,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_volume_mode Volume Mode information for PersistentVolume. + # HELP kube_persistentvolume_volume_mode Volume Mode information for the PersistentVolume. # TYPE kube_persistentvolume_volume_mode gauge kube_persistentvolume_volume_mode{persistentvolume="test-default-volumemode",volumemode="Filesystem"} 1 `, @@ -770,7 +770,7 @@ func TestPersistentVolumeStore(t *testing.T) { }, }, Want: ` - # HELP kube_persistentvolume_volume_mode Volume Mode information for PersistentVolume. + # HELP kube_persistentvolume_volume_mode Volume Mode information for the PersistentVolume. # TYPE kube_persistentvolume_volume_mode gauge kube_persistentvolume_volume_mode{persistentvolume="test-block-volumemode",volumemode="Block"} 1 `, From ef4fceac06f49b058549854950b6ec9947ac15cb Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Wed, 17 Apr 2024 09:51:05 +0100 Subject: [PATCH 004/154] refactor: reduce cyclomatic complexity Signed-off-by: Ricardo Lopes --- internal/store/persistentvolume.go | 758 +++++++++++++++-------------- 1 file changed, 399 insertions(+), 359 deletions(-) diff --git a/internal/store/persistentvolume.go b/internal/store/persistentvolume.go index 1f9e647748..b9e8ddb44b 100644 --- a/internal/store/persistentvolume.go +++ b/internal/store/persistentvolume.go @@ -50,396 +50,436 @@ var ( func persistentVolumeMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { return []generator.FamilyGenerator{ - *generator.NewFamilyGeneratorWithStability( - descPersistentVolumeClaimRefName, - descPersistentVolumeClaimRefHelp, - metric.Gauge, - basemetrics.STABLE, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - claimRef := p.Spec.ClaimRef - - if claimRef == nil { - return &metric.Family{ - Metrics: []*metric.Metric{}, - } - } + createPersistentVolumeClaimRef(), + createPersistentVolumeAnnotations(allowAnnotationsList), + createPersistentVolumeLabels(allowLabelsList), + createPersistentVolumeStatusPhase(), + createPersistentVolumeInfo(), + createPersistentVolumeCapacityBytes(), + createPersistentVolumeCreated(), + createPersistentVolumeDeletionTimestamp(), + createPersistentVolumeCSIAttributes(), + createPersistentVolumeMode(), + } +} + +func wrapPersistentVolumeFunc(f func(*v1.PersistentVolume) *metric.Family) func(interface{}) *metric.Family { + return func(obj interface{}) *metric.Family { + persistentVolume := obj.(*v1.PersistentVolume) + + metricFamily := f(persistentVolume) + + for _, m := range metricFamily.Metrics { + m.LabelKeys, m.LabelValues = mergeKeyValues(descPersistentVolumeLabelsDefaultLabels, []string{persistentVolume.Name}, m.LabelKeys, m.LabelValues) + } + + return metricFamily + } +} + +func createPersistentVolumeListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher { + return &cache.ListWatch{ + ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + return kubeClient.CoreV1().PersistentVolumes().List(context.TODO(), opts) + }, + WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + return kubeClient.CoreV1().PersistentVolumes().Watch(context.TODO(), opts) + }, + } +} + +func createPersistentVolumeClaimRef() generator.FamilyGenerator { + return *generator.NewFamilyGeneratorWithStability( + descPersistentVolumeClaimRefName, + descPersistentVolumeClaimRefHelp, + metric.Gauge, + basemetrics.STABLE, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + claimRef := p.Spec.ClaimRef + + if claimRef == nil { return &metric.Family{ - Metrics: []*metric.Metric{ - { - LabelKeys: []string{ - "name", - "claim_namespace", - }, - LabelValues: []string{ - p.Spec.ClaimRef.Name, - p.Spec.ClaimRef.Namespace, - }, - Value: 1, - }, - }, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - descPersistentVolumeAnnotationsName, - descPersistentVolumeAnnotationsHelp, - metric.Gauge, - basemetrics.ALPHA, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - if len(allowAnnotationsList) == 0 { - return &metric.Family{} + Metrics: []*metric.Metric{}, } - annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", p.Annotations, allowAnnotationsList) - return &metric.Family{ - Metrics: []*metric.Metric{ - { - LabelKeys: annotationKeys, - LabelValues: annotationValues, - Value: 1, + } + return &metric.Family{ + Metrics: []*metric.Metric{ + { + LabelKeys: []string{ + "name", + "claim_namespace", }, - }, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - descPersistentVolumeLabelsName, - descPersistentVolumeLabelsHelp, - metric.Gauge, - basemetrics.STABLE, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - if len(allowLabelsList) == 0 { - return &metric.Family{} - } - labelKeys, labelValues := createPrometheusLabelKeysValues("label", p.Labels, allowLabelsList) - return &metric.Family{ - Metrics: []*metric.Metric{ - { - LabelKeys: labelKeys, - LabelValues: labelValues, - Value: 1, + LabelValues: []string{ + p.Spec.ClaimRef.Name, + p.Spec.ClaimRef.Namespace, }, + Value: 1, }, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_persistentvolume_status_phase", - "The phase indicates if a volume is available, bound to a claim, or released by a claim.", - metric.Gauge, - basemetrics.STABLE, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - phase := p.Status.Phase - - if phase == "" { - return &metric.Family{ - Metrics: []*metric.Metric{}, - } - } + }, + } + }), + ) +} - // Set current phase to 1, others to 0 if it is set. - ms := []*metric.Metric{ - { - LabelValues: []string{string(v1.VolumePending)}, - Value: boolFloat64(phase == v1.VolumePending), - }, - { - LabelValues: []string{string(v1.VolumeAvailable)}, - Value: boolFloat64(phase == v1.VolumeAvailable), - }, +func createPersistentVolumeAnnotations(allowAnnotationsList []string) generator.FamilyGenerator { + return *generator.NewFamilyGeneratorWithStability( + descPersistentVolumeAnnotationsName, + descPersistentVolumeAnnotationsHelp, + metric.Gauge, + basemetrics.ALPHA, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + if len(allowAnnotationsList) == 0 { + return &metric.Family{} + } + annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", p.Annotations, allowAnnotationsList) + return &metric.Family{ + Metrics: []*metric.Metric{ { - LabelValues: []string{string(v1.VolumeBound)}, - Value: boolFloat64(phase == v1.VolumeBound), - }, - { - LabelValues: []string{string(v1.VolumeReleased)}, - Value: boolFloat64(phase == v1.VolumeReleased), + LabelKeys: annotationKeys, + LabelValues: annotationValues, + Value: 1, }, + }, + } + }), + ) +} + +func createPersistentVolumeLabels(allowLabelsList []string) generator.FamilyGenerator { + return *generator.NewFamilyGeneratorWithStability( + descPersistentVolumeLabelsName, + descPersistentVolumeLabelsHelp, + metric.Gauge, + basemetrics.STABLE, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + if len(allowLabelsList) == 0 { + return &metric.Family{} + } + labelKeys, labelValues := createPrometheusLabelKeysValues("label", p.Labels, allowLabelsList) + return &metric.Family{ + Metrics: []*metric.Metric{ { - LabelValues: []string{string(v1.VolumeFailed)}, - Value: boolFloat64(phase == v1.VolumeFailed), + LabelKeys: labelKeys, + LabelValues: labelValues, + Value: 1, }, - } + }, + } + }), + ) +} - for _, m := range ms { - m.LabelKeys = []string{"phase"} - } +func createPersistentVolumeStatusPhase() generator.FamilyGenerator { + return *generator.NewFamilyGeneratorWithStability( + "kube_persistentvolume_status_phase", + "The phase indicates if a volume is available, bound to a claim, or released by a claim.", + metric.Gauge, + basemetrics.STABLE, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + phase := p.Status.Phase + if phase == "" { return &metric.Family{ - Metrics: ms, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_persistentvolume_info", - "Information about persistentvolume.", - metric.Gauge, - basemetrics.STABLE, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - var ( - gcePDDiskName, - ebsVolumeID, - azureDiskName, - fcWWIDs, fcLun, fcTargetWWNs, - iscsiTargetPortal, iscsiIQN, iscsiLun, iscsiInitiatorName, - nfsServer, nfsPath, - csiDriver, csiVolumeHandle, - localFS, localPath, - hostPath, hostPathType string - ) - - switch { - case p.Spec.PersistentVolumeSource.GCEPersistentDisk != nil: - gcePDDiskName = p.Spec.PersistentVolumeSource.GCEPersistentDisk.PDName - case p.Spec.PersistentVolumeSource.AWSElasticBlockStore != nil: - ebsVolumeID = p.Spec.PersistentVolumeSource.AWSElasticBlockStore.VolumeID - case p.Spec.PersistentVolumeSource.AzureDisk != nil: - azureDiskName = p.Spec.PersistentVolumeSource.AzureDisk.DiskName - case p.Spec.PersistentVolumeSource.FC != nil: - if p.Spec.PersistentVolumeSource.FC.Lun != nil { - fcLun = strconv.FormatInt(int64(*p.Spec.PersistentVolumeSource.FC.Lun), 10) - } - for _, wwn := range p.Spec.PersistentVolumeSource.FC.TargetWWNs { - if len(fcTargetWWNs) != 0 { - fcTargetWWNs += "," - } - fcTargetWWNs += wwn - } - for _, wwid := range p.Spec.PersistentVolumeSource.FC.WWIDs { - if len(fcWWIDs) != 0 { - fcWWIDs += "," - } - fcWWIDs += wwid - } - case p.Spec.PersistentVolumeSource.ISCSI != nil: - iscsiTargetPortal = p.Spec.PersistentVolumeSource.ISCSI.TargetPortal - iscsiIQN = p.Spec.PersistentVolumeSource.ISCSI.IQN - iscsiLun = strconv.FormatInt(int64(p.Spec.PersistentVolumeSource.ISCSI.Lun), 10) - if p.Spec.PersistentVolumeSource.ISCSI.InitiatorName != nil { - iscsiInitiatorName = *p.Spec.PersistentVolumeSource.ISCSI.InitiatorName - } - case p.Spec.PersistentVolumeSource.NFS != nil: - nfsServer = p.Spec.PersistentVolumeSource.NFS.Server - nfsPath = p.Spec.PersistentVolumeSource.NFS.Path - case p.Spec.PersistentVolumeSource.CSI != nil: - csiDriver = p.Spec.PersistentVolumeSource.CSI.Driver - csiVolumeHandle = p.Spec.PersistentVolumeSource.CSI.VolumeHandle - case p.Spec.PersistentVolumeSource.Local != nil: - localPath = p.Spec.PersistentVolumeSource.Local.Path - if p.Spec.PersistentVolumeSource.Local.FSType != nil { - localFS = *p.Spec.PersistentVolumeSource.Local.FSType - } - case p.Spec.PersistentVolumeSource.HostPath != nil: - hostPath = p.Spec.PersistentVolumeSource.HostPath.Path - if p.Spec.PersistentVolumeSource.HostPath.Type != nil { - hostPathType = string(*p.Spec.PersistentVolumeSource.HostPath.Type) - } + Metrics: []*metric.Metric{}, } + } - return &metric.Family{ - Metrics: []*metric.Metric{ - { - LabelKeys: []string{ - "storageclass", - "gce_persistent_disk_name", - "ebs_volume_id", - "azure_disk_name", - "fc_wwids", - "fc_lun", - "fc_target_wwns", - "iscsi_target_portal", - "iscsi_iqn", - "iscsi_lun", - "iscsi_initiator_name", - "nfs_server", - "nfs_path", - "csi_driver", - "csi_volume_handle", - "local_path", - "local_fs", - "host_path", - "host_path_type", - }, - LabelValues: []string{ - p.Spec.StorageClassName, - gcePDDiskName, - ebsVolumeID, - azureDiskName, - fcWWIDs, - fcLun, - fcTargetWWNs, - iscsiTargetPortal, - iscsiIQN, - iscsiLun, - iscsiInitiatorName, - nfsServer, - nfsPath, - csiDriver, - csiVolumeHandle, - localPath, - localFS, - hostPath, - hostPathType, - }, - Value: 1, - }, - }, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_persistentvolume_capacity_bytes", - "Persistentvolume capacity in bytes.", - metric.Gauge, - basemetrics.STABLE, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - storage := p.Spec.Capacity[v1.ResourceStorage] - return &metric.Family{ - Metrics: []*metric.Metric{ - { - Value: float64(storage.Value()), - }, - }, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_persistentvolume_created", - "Unix creation timestamp", - metric.Gauge, - basemetrics.ALPHA, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - ms := []*metric.Metric{} - - if !p.CreationTimestamp.IsZero() { - ms = append(ms, &metric.Metric{ - LabelKeys: []string{}, - LabelValues: []string{}, - Value: float64(p.CreationTimestamp.Unix()), - }) - } + // Set current phase to 1, others to 0 if it is set. + ms := []*metric.Metric{ + { + LabelValues: []string{string(v1.VolumePending)}, + Value: boolFloat64(phase == v1.VolumePending), + }, + { + LabelValues: []string{string(v1.VolumeAvailable)}, + Value: boolFloat64(phase == v1.VolumeAvailable), + }, + { + LabelValues: []string{string(v1.VolumeBound)}, + Value: boolFloat64(phase == v1.VolumeBound), + }, + { + LabelValues: []string{string(v1.VolumeReleased)}, + Value: boolFloat64(phase == v1.VolumeReleased), + }, + { + LabelValues: []string{string(v1.VolumeFailed)}, + Value: boolFloat64(phase == v1.VolumeFailed), + }, + } - return &metric.Family{ - Metrics: ms, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_persistentvolume_deletion_timestamp", - "Unix deletion timestamp", - metric.Gauge, - basemetrics.ALPHA, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - ms := []*metric.Metric{} - - if p.DeletionTimestamp != nil && !p.DeletionTimestamp.IsZero() { - ms = append(ms, &metric.Metric{ - LabelKeys: []string{}, - LabelValues: []string{}, - Value: float64(p.DeletionTimestamp.Unix()), - }) - } + for _, m := range ms { + m.LabelKeys = []string{"phase"} + } - return &metric.Family{ - Metrics: ms, + return &metric.Family{ + Metrics: ms, + } + }), + ) +} + +func createPersistentVolumeInfo() generator.FamilyGenerator { + return *generator.NewFamilyGeneratorWithStability( + "kube_persistentvolume_info", + "Information about persistentvolume.", + metric.Gauge, + basemetrics.STABLE, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + var ( + gcePDDiskName, + ebsVolumeID, + azureDiskName, + fcWWIDs, fcLun, fcTargetWWNs, + iscsiTargetPortal, iscsiIQN, iscsiLun, iscsiInitiatorName, + nfsServer, nfsPath, + csiDriver, csiVolumeHandle, + localFS, localPath, + hostPath, hostPathType string + ) + + switch { + case p.Spec.PersistentVolumeSource.GCEPersistentDisk != nil: + gcePDDiskName = p.Spec.PersistentVolumeSource.GCEPersistentDisk.PDName + case p.Spec.PersistentVolumeSource.AWSElasticBlockStore != nil: + ebsVolumeID = p.Spec.PersistentVolumeSource.AWSElasticBlockStore.VolumeID + case p.Spec.PersistentVolumeSource.AzureDisk != nil: + azureDiskName = p.Spec.PersistentVolumeSource.AzureDisk.DiskName + case p.Spec.PersistentVolumeSource.FC != nil: + if p.Spec.PersistentVolumeSource.FC.Lun != nil { + fcLun = strconv.FormatInt(int64(*p.Spec.PersistentVolumeSource.FC.Lun), 10) } - }), - ), - *generator.NewOptInFamilyGenerator( - descPersistentVolumeCSIAttributesName, - descPersistentVolumeCSIAttributesHelp, - metric.Gauge, - basemetrics.ALPHA, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - if p.Spec.CSI == nil { - return &metric.Family{ - Metrics: []*metric.Metric{}, + for _, wwn := range p.Spec.PersistentVolumeSource.FC.TargetWWNs { + if len(fcTargetWWNs) != 0 { + fcTargetWWNs += "," } + fcTargetWWNs += wwn } - - var csiMounter, csiMapOptions string - for k, v := range p.Spec.PersistentVolumeSource.CSI.VolumeAttributes { - // storage attributes handled by external CEPH CSI driver - if k == "mapOptions" { - csiMapOptions = v - } else if k == "mounter" { - csiMounter = v + for _, wwid := range p.Spec.PersistentVolumeSource.FC.WWIDs { + if len(fcWWIDs) != 0 { + fcWWIDs += "," } + fcWWIDs += wwid } - - return &metric.Family{ - Metrics: []*metric.Metric{ - { - LabelKeys: []string{ - "csi_mounter", - "csi_map_options", - }, - LabelValues: []string{ - csiMounter, - csiMapOptions, - }, - Value: 1, - }, - }, + case p.Spec.PersistentVolumeSource.ISCSI != nil: + iscsiTargetPortal = p.Spec.PersistentVolumeSource.ISCSI.TargetPortal + iscsiIQN = p.Spec.PersistentVolumeSource.ISCSI.IQN + iscsiLun = strconv.FormatInt(int64(p.Spec.PersistentVolumeSource.ISCSI.Lun), 10) + if p.Spec.PersistentVolumeSource.ISCSI.InitiatorName != nil { + iscsiInitiatorName = *p.Spec.PersistentVolumeSource.ISCSI.InitiatorName + } + case p.Spec.PersistentVolumeSource.NFS != nil: + nfsServer = p.Spec.PersistentVolumeSource.NFS.Server + nfsPath = p.Spec.PersistentVolumeSource.NFS.Path + case p.Spec.PersistentVolumeSource.CSI != nil: + csiDriver = p.Spec.PersistentVolumeSource.CSI.Driver + csiVolumeHandle = p.Spec.PersistentVolumeSource.CSI.VolumeHandle + case p.Spec.PersistentVolumeSource.Local != nil: + localPath = p.Spec.PersistentVolumeSource.Local.Path + if p.Spec.PersistentVolumeSource.Local.FSType != nil { + localFS = *p.Spec.PersistentVolumeSource.Local.FSType } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_persistentvolume_volume_mode", - "Volume Mode information for the PersistentVolume.", - metric.Gauge, - basemetrics.ALPHA, - "", - wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { - volumeMode := "" - if p.Spec.VolumeMode != nil { - volumeMode = string(*p.Spec.VolumeMode) - } else { - volumeMode = string("Filesystem") // Filesystem is the default mode used when volumeMode parameter is omitted. + case p.Spec.PersistentVolumeSource.HostPath != nil: + hostPath = p.Spec.PersistentVolumeSource.HostPath.Path + if p.Spec.PersistentVolumeSource.HostPath.Type != nil { + hostPathType = string(*p.Spec.PersistentVolumeSource.HostPath.Type) } + } - return &metric.Family{ - Metrics: []*metric.Metric{ - { - LabelKeys: []string{"volumemode"}, - LabelValues: []string{volumeMode}, - Value: 1, + return &metric.Family{ + Metrics: []*metric.Metric{ + { + LabelKeys: []string{ + "storageclass", + "gce_persistent_disk_name", + "ebs_volume_id", + "azure_disk_name", + "fc_wwids", + "fc_lun", + "fc_target_wwns", + "iscsi_target_portal", + "iscsi_iqn", + "iscsi_lun", + "iscsi_initiator_name", + "nfs_server", + "nfs_path", + "csi_driver", + "csi_volume_handle", + "local_path", + "local_fs", + "host_path", + "host_path_type", }, - }} - }), - ), - } + LabelValues: []string{ + p.Spec.StorageClassName, + gcePDDiskName, + ebsVolumeID, + azureDiskName, + fcWWIDs, + fcLun, + fcTargetWWNs, + iscsiTargetPortal, + iscsiIQN, + iscsiLun, + iscsiInitiatorName, + nfsServer, + nfsPath, + csiDriver, + csiVolumeHandle, + localPath, + localFS, + hostPath, + hostPathType, + }, + Value: 1, + }, + }, + } + }), + ) } -func wrapPersistentVolumeFunc(f func(*v1.PersistentVolume) *metric.Family) func(interface{}) *metric.Family { - return func(obj interface{}) *metric.Family { - persistentVolume := obj.(*v1.PersistentVolume) +func createPersistentVolumeCapacityBytes() generator.FamilyGenerator { + return *generator.NewFamilyGeneratorWithStability( + "kube_persistentvolume_capacity_bytes", + "Persistentvolume capacity in bytes.", + metric.Gauge, + basemetrics.STABLE, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + storage := p.Spec.Capacity[v1.ResourceStorage] + return &metric.Family{ + Metrics: []*metric.Metric{ + { + Value: float64(storage.Value()), + }, + }, + } + }), + ) +} - metricFamily := f(persistentVolume) +func createPersistentVolumeCreated() generator.FamilyGenerator { + return *generator.NewFamilyGeneratorWithStability( + "kube_persistentvolume_created", + "Unix creation timestamp", + metric.Gauge, + basemetrics.ALPHA, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + ms := []*metric.Metric{} - for _, m := range metricFamily.Metrics { - m.LabelKeys, m.LabelValues = mergeKeyValues(descPersistentVolumeLabelsDefaultLabels, []string{persistentVolume.Name}, m.LabelKeys, m.LabelValues) - } + if !p.CreationTimestamp.IsZero() { + ms = append(ms, &metric.Metric{ + LabelKeys: []string{}, + LabelValues: []string{}, + Value: float64(p.CreationTimestamp.Unix()), + }) + } - return metricFamily - } + return &metric.Family{ + Metrics: ms, + } + }), + ) } -func createPersistentVolumeListWatch(kubeClient clientset.Interface, _ string, _ string) cache.ListerWatcher { - return &cache.ListWatch{ - ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { - return kubeClient.CoreV1().PersistentVolumes().List(context.TODO(), opts) - }, - WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { - return kubeClient.CoreV1().PersistentVolumes().Watch(context.TODO(), opts) - }, - } +func createPersistentVolumeDeletionTimestamp() generator.FamilyGenerator { + return *generator.NewFamilyGeneratorWithStability( + "kube_persistentvolume_deletion_timestamp", + "Unix deletion timestamp", + metric.Gauge, + basemetrics.ALPHA, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + ms := []*metric.Metric{} + + if p.DeletionTimestamp != nil && !p.DeletionTimestamp.IsZero() { + ms = append(ms, &metric.Metric{ + LabelKeys: []string{}, + LabelValues: []string{}, + Value: float64(p.DeletionTimestamp.Unix()), + }) + } + + return &metric.Family{ + Metrics: ms, + } + }), + ) +} + +func createPersistentVolumeCSIAttributes() generator.FamilyGenerator { + return *generator.NewOptInFamilyGenerator( + descPersistentVolumeCSIAttributesName, + descPersistentVolumeCSIAttributesHelp, + metric.Gauge, + basemetrics.ALPHA, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + if p.Spec.CSI == nil { + return &metric.Family{ + Metrics: []*metric.Metric{}, + } + } + + var csiMounter, csiMapOptions string + for k, v := range p.Spec.PersistentVolumeSource.CSI.VolumeAttributes { + // storage attributes handled by external CEPH CSI driver + if k == "mapOptions" { + csiMapOptions = v + } else if k == "mounter" { + csiMounter = v + } + } + + return &metric.Family{ + Metrics: []*metric.Metric{ + { + LabelKeys: []string{ + "csi_mounter", + "csi_map_options", + }, + LabelValues: []string{ + csiMounter, + csiMapOptions, + }, + Value: 1, + }, + }, + } + }), + ) +} + +func createPersistentVolumeMode() generator.FamilyGenerator { + return *generator.NewFamilyGeneratorWithStability( + "kube_persistentvolume_volume_mode", + "Volume Mode information for the PersistentVolume.", + metric.Gauge, + basemetrics.ALPHA, + "", + wrapPersistentVolumeFunc(func(p *v1.PersistentVolume) *metric.Family { + volumeMode := "" + if p.Spec.VolumeMode != nil { + volumeMode = string(*p.Spec.VolumeMode) + } else { + volumeMode = string("Filesystem") // Filesystem is the default mode used when volumeMode parameter is omitted. + } + + return &metric.Family{ + Metrics: []*metric.Metric{ + { + LabelKeys: []string{"volumemode"}, + LabelValues: []string{volumeMode}, + Value: 1, + }, + }} + }), + ) } From b1b8d24cbf421d2b75b9ecf0442f852a7fc55761 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Wed, 17 Apr 2024 09:52:05 +0100 Subject: [PATCH 005/154] refactor: remove unused var Signed-off-by: Ricardo Lopes --- internal/store/persistentvolume.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/store/persistentvolume.go b/internal/store/persistentvolume.go index b9e8ddb44b..33d8ca0038 100644 --- a/internal/store/persistentvolume.go +++ b/internal/store/persistentvolume.go @@ -34,9 +34,8 @@ import ( ) var ( - descPersistentVolumeClaimRefName = "kube_persistentvolume_claim_ref" - descPersistentVolumeClaimRefHelp = "Information about the Persistent Volume Claim Reference." - descPersistentVolumeClaimRefDefaultLabels = []string{"persistentvolume"} + descPersistentVolumeClaimRefName = "kube_persistentvolume_claim_ref" + descPersistentVolumeClaimRefHelp = "Information about the Persistent Volume Claim Reference." descPersistentVolumeAnnotationsName = "kube_persistentvolume_annotations" descPersistentVolumeAnnotationsHelp = "Kubernetes annotations converted to Prometheus labels." From 86846679a364f84ba277d784cc25f3106f5efb97 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 09:27:11 +0000 Subject: [PATCH 006/154] build(deps): Bump github.com/prometheus/common from 0.52.3 to 0.53.0 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.52.3 to 0.53.0. - [Release notes](https://github.com/prometheus/common/releases) - [Commits](https://github.com/prometheus/common/compare/v0.52.3...v0.53.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3290a5099b..03602ca493 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.19.0 github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common v0.52.3 + github.com/prometheus/common v0.53.0 github.com/prometheus/exporter-toolkit v0.11.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.0 diff --git a/go.sum b/go.sum index 6a5ffa7b2f..020896bef3 100644 --- a/go.sum +++ b/go.sum @@ -109,8 +109,8 @@ github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7km github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.52.3 h1:5f8uj6ZwHSscOGNdIQg6OiZv/ybiK2CO2q2drVZAQSA= -github.com/prometheus/common v0.52.3/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= +github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= +github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= From 6d8f7573aaa194e4f29e574156b7aa1bcc16108c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 22 Apr 2024 20:15:26 +0200 Subject: [PATCH 007/154] feat: Support k8s 1.30 --- README.md | 2 +- data.yaml | 2 +- go.mod | 20 +++++++++++--------- go.sum | 44 ++++++++++++++++++++++---------------------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 1aaf5d1391..fbebaaf9fc 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Generally, it is recommended to use the latest release of kube-state-metrics. If | **v2.10.1** | v1.27 | | **v2.11.0** | v1.28 | | **v2.12.0** | v1.29 | -| **main** | v1.29 | +| **main** | v1.30 | #### Resource group version compatibility diff --git a/data.yaml b/data.yaml index 66a7f80c71..22ed73d56b 100644 --- a/data.yaml +++ b/data.yaml @@ -16,4 +16,4 @@ compat: - version: "v2.12.0" kubernetes: "1.29" - version: "main" - kubernetes: "1.29" + kubernetes: "1.30" diff --git a/go.mod b/go.mod index 03602ca493..4bf12e4967 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module k8s.io/kube-state-metrics/v2 -go 1.21 +go 1.22.0 + +toolchain go1.22.2 require ( github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 @@ -17,13 +19,13 @@ require ( github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.29.3 - k8s.io/apimachinery v0.29.3 - k8s.io/client-go v0.29.3 - k8s.io/component-base v0.29.3 + k8s.io/api v0.30.0 + k8s.io/apimachinery v0.30.0 + k8s.io/client-go v0.30.0 + k8s.io/component-base v0.30.0 k8s.io/klog/v2 v2.120.1 - k8s.io/sample-controller v0.29.3 - k8s.io/utils v0.0.0-20230726121419-3b25d923346b + k8s.io/sample-controller v0.30.0 + k8s.io/utils v0.0.0-20240310230437-4693a0247e57 ) require ( @@ -72,7 +74,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.22.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.18.0 // indirect @@ -84,7 +86,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect + k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/go.sum b/go.sum index 020896bef3..502bb5f068 100644 --- a/go.sum +++ b/go.sum @@ -94,10 +94,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= -github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= -github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= -github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= -github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= +github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/gomega v1.31.0 h1:54UJxxj6cPInHS3a35wm6BK/F9nHYueZ1NVujHDrnXE= +github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -166,8 +166,8 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -193,8 +193,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -216,22 +216,22 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.29.3 h1:2ORfZ7+bGC3YJqGpV0KSDDEVf8hdGQ6A03/50vj8pmw= -k8s.io/api v0.29.3/go.mod h1:y2yg2NTyHUUkIoTC+phinTnEa3KFM6RZ3szxt014a80= -k8s.io/apimachinery v0.29.3 h1:2tbx+5L7RNvqJjn7RIuIKu9XTsIZ9Z5wX2G22XAa5EU= -k8s.io/apimachinery v0.29.3/go.mod h1:hx/S4V2PNW4OMg3WizRrHutyB5la0iCUbZym+W0EQIU= -k8s.io/client-go v0.29.3 h1:R/zaZbEAxqComZ9FHeQwOh3Y1ZUs7FaHKZdQtIc2WZg= -k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0= -k8s.io/component-base v0.29.3 h1:Oq9/nddUxlnrCuuR2K/jp6aflVvc0uDvxMzAWxnGzAo= -k8s.io/component-base v0.29.3/go.mod h1:Yuj33XXjuOk2BAaHsIGHhCKZQAgYKhqIxIjIr2UXYio= +k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA= +k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE= +k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= +k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/client-go v0.30.0 h1:sB1AGGlhY/o7KCyCEQ0bPWzYDL0pwOZO4vAtTSh/gJQ= +k8s.io/client-go v0.30.0/go.mod h1:g7li5O5256qe6TYdAMyX/otJqMhIiGgTapdLchhmOaY= +k8s.io/component-base v0.30.0 h1:cj6bp38g0ainlfYtaOQuRELh5KSYjhKxM+io7AUIk4o= +k8s.io/component-base v0.30.0/go.mod h1:V9x/0ePFNaKeKYA3bOvIbrNoluTSG+fSJKjLdjOoeXQ= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= -k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= -k8s.io/sample-controller v0.29.3 h1:1g96iu1sH9zFaZ4Nq7s10R1eq1cNgiM9l/F4ttEURJI= -k8s.io/sample-controller v0.29.3/go.mod h1:zjhfoVX5Bcf7G4yNUoUmhXbVMMqM+TUoz3pILzH0OLo= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= +k8s.io/sample-controller v0.30.0 h1:XBYx3RxVCqtY8rp4CAmKbJ6o+LZfXdU3UnO8qZccO14= +k8s.io/sample-controller v0.30.0/go.mod h1:IR3rNY6brFmMKwUHuyORymQgEoXFhQCI0ROmkx9dTw8= +k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY= +k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= From a0f5ebef42a651ffbad8f4175a872944790b8c46 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Wed, 24 Apr 2024 17:17:59 +0100 Subject: [PATCH 008/154] ci: generate sbom on release Signed-off-by: Ricardo Lopes --- .github/workflows/sbom.yaml | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/sbom.yaml diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml new file mode 100644 index 0000000000..7fa9d16ba5 --- /dev/null +++ b/.github/workflows/sbom.yaml @@ -0,0 +1,41 @@ +name: Generate SBOM with Kubernetes BOM + +on: + release: + types: + - published + +permissions: + contents: read + +jobs: + sbom: + runs-on: ubuntu-latest + + permissions: + contents: write + + env: + OUTPUT: kube-state-metrics-${{ github.ref_name }}.spdx + TAG: ${{ github.ref_name }} + + steps: + - name: Fetch source code into GITHUB_WORKSPACE + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + + - name: Install Kubernetes BOM + uses: kubernetes-sigs/release-actions/setup-bom@841d76a188a7c121231a863572e27012805715a2 # v0.1.4 + + - name: Generate SBOM + run: | + bom generate \ + --dirs=. \ + --image=registry.k8s.io/kube-state-metrics/kube-state-metrics:$TAG \ + --namespace=https://github.com/kubernetes/kube-state-metrics/releases/download/$TAG/$OUTPUT + --output=$OUTPUT + + - name: Upload SBOM to GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload $TAG $OUTPUT From 7fc6c5dd2e6596d6534587497c2821c090bf9555 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Thu, 25 Apr 2024 15:44:33 +0100 Subject: [PATCH 009/154] ci: fetch tag name on release Signed-off-by: Ricardo Lopes --- .github/workflows/sbom.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index 7fa9d16ba5..819cc133d6 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -16,8 +16,8 @@ jobs: contents: write env: - OUTPUT: kube-state-metrics-${{ github.ref_name }}.spdx - TAG: ${{ github.ref_name }} + OUTPUT: kube-state-metrics-${{ github.event.release.tag_name }}.spdx + TAG: ${{ github.event.release.tag_name }} steps: - name: Fetch source code into GITHUB_WORKSPACE From 2a235100190e26cf42799f5eacbd77eb7daa6857 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Thu, 25 Apr 2024 16:18:56 +0100 Subject: [PATCH 010/154] ci: trigger on release but not on pre-release Signed-off-by: Ricardo Lopes --- .github/workflows/sbom.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index 819cc133d6..3a5e861b8b 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -3,7 +3,7 @@ name: Generate SBOM with Kubernetes BOM on: release: types: - - published + - released permissions: contents: read From a5e168f26953c39e296d5ae88604717ff7d88a49 Mon Sep 17 00:00:00 2001 From: Jason Wilder Date: Wed, 1 May 2024 09:01:14 -0600 Subject: [PATCH 011/154] build: bump deps to fix CVEs Updates all deps flagging for fixed CVEs and updates go to 1.22.2. Fixes CVE-2022-21698 CVE-2022-46146 CVE-2021-43565 CVE-2022-27191 CVE-2023-48795 CVE-2022-27664 CVE-2022-41723 CVE-2023-39325 CVE-2023-3978 CVE-2023-44487 CVE-2023-45288 CVE-2022-29526 CVE-2021-38561 CVE-2022-32149 CVE-2024-24786 CVE-2022-28948 --- Makefile | 2 +- go.mod | 6 +++--- go.sum | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index b0d92fd5ab..f49c08d9ca 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ lint: shellcheck licensecheck lint-markdown-format lint-fix: fix-markdown-format golangci-lint run --fix -v - + doccheck: generate validate-template @echo "- Checking if the generated documentation is up to date..." diff --git a/go.mod b/go.mod index 4bf12e4967..ca08d14a55 100644 --- a/go.mod +++ b/go.mod @@ -77,12 +77,12 @@ require ( golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sync v0.5.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.34.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 502bb5f068..6762d1dc00 100644 --- a/go.sum +++ b/go.sum @@ -178,10 +178,10 @@ golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -201,8 +201,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= +google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= From 93e8d99a7de7801be99dda5dc9270582f2cb4022 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 09:07:30 +0000 Subject: [PATCH 012/154] build(deps): Bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.19.0 to 1.19.1. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.19.0...v1.19.1) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4bf12e4967..86180c5850 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/gobuffalo/flect v1.0.2 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 - github.com/prometheus/client_golang v1.19.0 + github.com/prometheus/client_golang v1.19.1 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.53.0 github.com/prometheus/exporter-toolkit v0.11.0 diff --git a/go.sum b/go.sum index 502bb5f068..ada41e8f42 100644 --- a/go.sum +++ b/go.sum @@ -105,8 +105,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= -github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= From 2b2d1dc133cf0bb8964f8e763be8db0ab5ac995c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 09:15:39 +0000 Subject: [PATCH 013/154] build(deps): Bump the k8s-dependencies group with 5 updates Bumps the k8s-dependencies group with 5 updates: | Package | From | To | | --- | --- | --- | | [k8s.io/api](https://github.com/kubernetes/api) | `0.30.0` | `0.30.1` | | [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) | `0.30.0` | `0.30.1` | | [k8s.io/client-go](https://github.com/kubernetes/client-go) | `0.30.0` | `0.30.1` | | [k8s.io/component-base](https://github.com/kubernetes/component-base) | `0.30.0` | `0.30.1` | | [k8s.io/sample-controller](https://github.com/kubernetes/sample-controller) | `0.30.0` | `0.30.1` | Updates `k8s.io/api` from 0.30.0 to 0.30.1 - [Commits](https://github.com/kubernetes/api/compare/v0.30.0...v0.30.1) Updates `k8s.io/apimachinery` from 0.30.0 to 0.30.1 - [Commits](https://github.com/kubernetes/apimachinery/compare/v0.30.0...v0.30.1) Updates `k8s.io/client-go` from 0.30.0 to 0.30.1 - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes/client-go/compare/v0.30.0...v0.30.1) Updates `k8s.io/component-base` from 0.30.0 to 0.30.1 - [Commits](https://github.com/kubernetes/component-base/compare/v0.30.0...v0.30.1) Updates `k8s.io/sample-controller` from 0.30.0 to 0.30.1 - [Commits](https://github.com/kubernetes/sample-controller/compare/v0.30.0...v0.30.1) --- updated-dependencies: - dependency-name: k8s.io/api dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/apimachinery dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/client-go dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/component-base dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/sample-controller dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 07ec843114..eb795bfc50 100644 --- a/go.mod +++ b/go.mod @@ -19,12 +19,12 @@ require ( github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.30.0 - k8s.io/apimachinery v0.30.0 - k8s.io/client-go v0.30.0 - k8s.io/component-base v0.30.0 + k8s.io/api v0.30.1 + k8s.io/apimachinery v0.30.1 + k8s.io/client-go v0.30.1 + k8s.io/component-base v0.30.1 k8s.io/klog/v2 v2.120.1 - k8s.io/sample-controller v0.30.0 + k8s.io/sample-controller v0.30.1 k8s.io/utils v0.0.0-20240310230437-4693a0247e57 ) diff --git a/go.sum b/go.sum index 91ead89693..9f1ae09d34 100644 --- a/go.sum +++ b/go.sum @@ -216,20 +216,20 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA= -k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE= -k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= -k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/client-go v0.30.0 h1:sB1AGGlhY/o7KCyCEQ0bPWzYDL0pwOZO4vAtTSh/gJQ= -k8s.io/client-go v0.30.0/go.mod h1:g7li5O5256qe6TYdAMyX/otJqMhIiGgTapdLchhmOaY= -k8s.io/component-base v0.30.0 h1:cj6bp38g0ainlfYtaOQuRELh5KSYjhKxM+io7AUIk4o= -k8s.io/component-base v0.30.0/go.mod h1:V9x/0ePFNaKeKYA3bOvIbrNoluTSG+fSJKjLdjOoeXQ= +k8s.io/api v0.30.1 h1:kCm/6mADMdbAxmIh0LBjS54nQBE+U4KmbCfIkF5CpJY= +k8s.io/api v0.30.1/go.mod h1:ddbN2C0+0DIiPntan/bye3SW3PdwLa11/0yqwvuRrJM= +k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U= +k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/client-go v0.30.1 h1:uC/Ir6A3R46wdkgCV3vbLyNOYyCJ8oZnjtJGKfytl/Q= +k8s.io/client-go v0.30.1/go.mod h1:wrAqLNs2trwiCH/wxxmT/x3hKVH9PuV0GGW0oDoHVqc= +k8s.io/component-base v0.30.1 h1:bvAtlPh1UrdaZL20D9+sWxsJljMi0QZ3Lmw+kmZAaxQ= +k8s.io/component-base v0.30.1/go.mod h1:e/X9kDiOebwlI41AvBHuWdqFriSRrX50CdwA9TFaHLI= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= -k8s.io/sample-controller v0.30.0 h1:XBYx3RxVCqtY8rp4CAmKbJ6o+LZfXdU3UnO8qZccO14= -k8s.io/sample-controller v0.30.0/go.mod h1:IR3rNY6brFmMKwUHuyORymQgEoXFhQCI0ROmkx9dTw8= +k8s.io/sample-controller v0.30.1 h1:X5MElr3bSf6Fe5k483EyM8RkeEdPEqheMU8rkjS1wYc= +k8s.io/sample-controller v0.30.1/go.mod h1:AagDyBDgEb7nXTFJXyWDDz/XPWmtq+ly02EPMpHicPQ= k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY= k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= From 8867e6ece9e0cbdbd27b9debea46de34a775cea5 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Wed, 22 May 2024 15:49:26 +0100 Subject: [PATCH 014/154] Restrict permissions for GITHUB_TOKEN Signed-off-by: Ricardo Lopes --- .github/workflows/openvex.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index c76c425d38..8ca3945dca 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -4,6 +4,10 @@ on: workflow_dispatch: release: types: [published] + +permissions: + contents: read + jobs: vexctl: runs-on: ubuntu-latest From b983ed5f42245d25e9b423518ff8518dc904e132 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Wed, 22 May 2024 17:04:08 +0100 Subject: [PATCH 015/154] Pin dependencies in GitHub Actions by hash Signed-off-by: Ricardo Lopes --- .github/workflows/ci.yml | 34 +++++++++++++++---------------- .github/workflows/govulncheck.yml | 4 ++-- .github/workflows/openvex.yml | 2 +- .github/workflows/semantic.yml | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 10c20f4c28..ae055fe7df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,10 +29,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Set up Go 1.x - uses: actions/setup-go@v5 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: ${{ env.GO_VERSION }} id: go @@ -51,10 +51,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Set up Go 1.x - uses: actions/setup-go@v5 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: ${{ env.GO_VERSION }} id: go @@ -72,10 +72,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Set up Go 1.x - uses: actions/setup-go@v5 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: ${{ env.GO_VERSION }} id: go @@ -93,10 +93,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Set up Go 1.x - uses: actions/setup-go@v5 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: ${{ env.GO_VERSION }} id: go @@ -114,10 +114,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Set up Go 1.x - uses: actions/setup-go@v5 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: ${{ env.GO_VERSION }} id: go @@ -135,7 +135,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup promtool run: | @@ -150,10 +150,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Set up Go 1.x - uses: actions/setup-go@v5 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: ${{ env.GO_VERSION }} id: go @@ -171,10 +171,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Set up Go 1.x - uses: actions/setup-go@v5 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: ${{ env.GO_VERSION }} id: go @@ -192,10 +192,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Set up Go 1.x - uses: actions/setup-go@v5 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: ${{ env.GO_VERSION }} id: go diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index ff311c5552..8d166fe997 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -15,10 +15,10 @@ jobs: ci-security-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 name: Checkout code - name: Set up Go 1.x - uses: actions/setup-go@v5 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: ${{ env.GO_VERSION }} - name: Install govulncheck binary diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index c76c425d38..f740f9ea7b 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Set environment variables run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - uses: openvex/generate-vex@c59881b41451d7ccba5c3b74cd195382b8971fcd diff --git a/.github/workflows/semantic.yml b/.github/workflows/semantic.yml index c2f6094adb..3ec84d62a0 100644 --- a/.github/workflows/semantic.yml +++ b/.github/workflows/semantic.yml @@ -18,6 +18,6 @@ jobs: name: Validate PR title for semantic commit message runs-on: ubuntu-latest steps: - - uses: amannn/action-semantic-pull-request@v5 + - uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f # v5.4.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b6697e516611aa7e77d627af27d01c0ef98d6c58 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Fri, 24 May 2024 09:18:22 +0100 Subject: [PATCH 016/154] ci: rename asset to pass CLOMonitor checks Signed-off-by: Ricardo Lopes --- .github/workflows/sbom.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index 3a5e861b8b..ea82cb0125 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -16,7 +16,7 @@ jobs: contents: write env: - OUTPUT: kube-state-metrics-${{ github.event.release.tag_name }}.spdx + OUTPUT: sbom.spdx TAG: ${{ github.event.release.tag_name }} steps: From d01fb796da296db693d28d0ec1fd40f850e17323 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 09:16:49 +0000 Subject: [PATCH 017/154] build(deps): Bump amannn/action-semantic-pull-request Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) from 5.4.0 to 5.5.2. - [Release notes](https://github.com/amannn/action-semantic-pull-request/releases) - [Changelog](https://github.com/amannn/action-semantic-pull-request/blob/main/CHANGELOG.md) - [Commits](https://github.com/amannn/action-semantic-pull-request/compare/e9fabac35e210fea40ca5b14c0da95a099eff26f...cfb60706e18bc85e8aec535e3c577abe8f70378e) --- updated-dependencies: - dependency-name: amannn/action-semantic-pull-request dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/semantic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/semantic.yml b/.github/workflows/semantic.yml index 3ec84d62a0..30724a98f2 100644 --- a/.github/workflows/semantic.yml +++ b/.github/workflows/semantic.yml @@ -18,6 +18,6 @@ jobs: name: Validate PR title for semantic commit message runs-on: ubuntu-latest steps: - - uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f # v5.4.0 + - uses: amannn/action-semantic-pull-request@cfb60706e18bc85e8aec535e3c577abe8f70378e # v5.5.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 8c75a8b589af57269fabdaa21875bc122bc7342b Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Mon, 27 May 2024 11:52:06 +0100 Subject: [PATCH 018/154] docs: add policy for consuming and upgrading dependencies Signed-off-by: Ricardo Lopes --- SECURITY-INSIGHTS.yml | 2 ++ docs/dependencies-policy.md | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 docs/dependencies-policy.md diff --git a/SECURITY-INSIGHTS.yml b/SECURITY-INSIGHTS.yml index 619041dc6b..0750830c69 100644 --- a/SECURITY-INSIGHTS.yml +++ b/SECURITY-INSIGHTS.yml @@ -32,6 +32,8 @@ dependencies: dependencies-lists: - https://github.com/kubernetes/kube-state-metrics/blob/main/go.mod - https://github.com/kubernetes/kube-state-metrics/blob/main/Dockerfile + env-dependencies-policy: + policy-url: https://github.com/kubernetes/kube-state-metrics/blob/main/docs/dependencies-policy.md documentation: - https://github.com/kubernetes/kube-state-metrics/tree/main/docs security-testing: diff --git a/docs/dependencies-policy.md b/docs/dependencies-policy.md new file mode 100644 index 0000000000..d998321419 --- /dev/null +++ b/docs/dependencies-policy.md @@ -0,0 +1,43 @@ +# Dependencies Policy + +## Purpose + +This policy describes how kube-state-metrics maintainers consume third-party packages. + +## Scope + +This policy applies to all kube-state-metrics maintainers and all third-party packages used in the kube-state-metrics project. + +## Policy + +kube-state-metrics maintainers must follow these guidelines when consuming third-party packages: + +- Only use third-party packages that are necessary for the functionality of kube-state-metrics. +- Use the latest version of all third-party packages whenever possible. +- Avoid using third-party packages that are known to have security vulnerabilities. +- Pin all third-party packages to specific versions in the kube-state-metrics codebase. +- Use a dependency management tool, such as Go modules, to manage third-party dependencies. + +## Procedure + +When adding a new third-party package to kube-state-metrics, maintainers must follow these steps: + +1. Evaluate the need for the package. Is it necessary for the functionality of kube-state-metrics? +2. Research the package. Is it actively maintained? Does it have a good reputation? +3. Choose a version of the package. Use the latest version whenever possible. +4. Pin the package to the specific version in the kube-state-metrics codebase. +5. Update the kube-state-metrics documentation to reflect the new dependency. + +## Enforcement + +This policy is enforced by the kube-state-metrics maintainers. + +Maintainers are expected to review each other's code changes to ensure that they comply with this policy. + +## Exceptions + +Exceptions to this policy may be granted by the kube-state-metrics project owners on a case-by-case basis. + +## Credits + +This policy was adapted from Kubescape's [Environment Dependencies Policy](https://github.com/kubescape/kubescape/blob/master/docs/environment-dependencies-policy.md). From 9917008f7ef20dc4035125d8327f0e0a2d050248 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Tue, 28 May 2024 10:31:31 +0100 Subject: [PATCH 019/154] docs: lint markdown Signed-off-by: Ricardo Lopes --- docs/dependencies-policy.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/dependencies-policy.md b/docs/dependencies-policy.md index d998321419..d1e0d5e945 100644 --- a/docs/dependencies-policy.md +++ b/docs/dependencies-policy.md @@ -12,20 +12,20 @@ This policy applies to all kube-state-metrics maintainers and all third-party pa kube-state-metrics maintainers must follow these guidelines when consuming third-party packages: -- Only use third-party packages that are necessary for the functionality of kube-state-metrics. -- Use the latest version of all third-party packages whenever possible. -- Avoid using third-party packages that are known to have security vulnerabilities. -- Pin all third-party packages to specific versions in the kube-state-metrics codebase. -- Use a dependency management tool, such as Go modules, to manage third-party dependencies. +* Only use third-party packages that are necessary for the functionality of kube-state-metrics. +* Use the latest version of all third-party packages whenever possible. +* Avoid using third-party packages that are known to have security vulnerabilities. +* Pin all third-party packages to specific versions in the kube-state-metrics codebase. +* Use a dependency management tool, such as Go modules, to manage third-party dependencies. ## Procedure When adding a new third-party package to kube-state-metrics, maintainers must follow these steps: -1. Evaluate the need for the package. Is it necessary for the functionality of kube-state-metrics? -2. Research the package. Is it actively maintained? Does it have a good reputation? -3. Choose a version of the package. Use the latest version whenever possible. -4. Pin the package to the specific version in the kube-state-metrics codebase. +1. Evaluate the need for the package. Is it necessary for the functionality of kube-state-metrics? +2. Research the package. Is it actively maintained? Does it have a good reputation? +3. Choose a version of the package. Use the latest version whenever possible. +4. Pin the package to the specific version in the kube-state-metrics codebase. 5. Update the kube-state-metrics documentation to reflect the new dependency. ## Enforcement From bb0a33c7a681938f8b5b18648d953cd30c5e6355 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:44:31 +0000 Subject: [PATCH 020/154] build(deps): Bump github.com/hairyhenderson/gomplate/v3 in /tools Bumps [github.com/hairyhenderson/gomplate/v3](https://github.com/hairyhenderson/gomplate) from 3.11.7 to 3.11.8. - [Release notes](https://github.com/hairyhenderson/gomplate/releases) - [Changelog](https://github.com/hairyhenderson/gomplate/blob/main/CHANGELOG.md) - [Commits](https://github.com/hairyhenderson/gomplate/compare/v3.11.7...v3.11.8) --- updated-dependencies: - dependency-name: github.com/hairyhenderson/gomplate/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- tools/go.mod | 18 +++++++++--------- tools/go.sum | 37 ++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/tools/go.mod b/tools/go.mod index 3f84208e77..abab5867a0 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -6,7 +6,7 @@ require ( github.com/brancz/gojsontoyaml v0.1.0 github.com/campoy/embedmd v1.0.0 github.com/google/go-jsonnet v0.20.0 - github.com/hairyhenderson/gomplate/v3 v3.11.7 + github.com/hairyhenderson/gomplate/v3 v3.11.8 github.com/jsonnet-bundler/jsonnet-bundler v0.5.1 golang.org/x/perf v0.0.0-20231127181059-b53752263861 ) @@ -119,20 +119,20 @@ require ( github.com/ugorji/go/codec v1.2.7 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/zealic/xignore v0.3.3 // indirect - go.etcd.io/bbolt v1.3.6 // indirect + go.etcd.io/bbolt v1.3.10 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/atomic v1.9.0 // indirect go4.org/intern v0.0.0-20230205224052-192e9f60865c // indirect go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect gocloud.dev v0.25.1-0.20220408200107-09b10f7359f7 // indirect - golang.org/x/crypto v0.18.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.19.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect - golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.16.0 // indirect - golang.org/x/term v0.16.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sync v0.5.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/term v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect golang.org/x/tools v0.13.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect @@ -142,7 +142,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/grpc v1.59.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/tools/go.sum b/tools/go.sum index fabd55cb93..7d8da6ff96 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -485,8 +485,8 @@ github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:Fecb github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hairyhenderson/go-fsimpl v0.0.0-20220529183339-9deae3e35047 h1:nSSfN9G8O8XXDqB3aDEHJ8K+0llYYToNlTcWOe1Pti8= github.com/hairyhenderson/go-fsimpl v0.0.0-20220529183339-9deae3e35047/go.mod h1:30RY4Ey+bg+BGKBufZE2IEmxk7hok9U9mjdgZYomwN4= -github.com/hairyhenderson/gomplate/v3 v3.11.7 h1:fpOTFZsX4mCfp3E6jodUfurHjCcW2ixRrMtyGg78sgU= -github.com/hairyhenderson/gomplate/v3 v3.11.7/go.mod h1:5VhCNPRpC2ahGESvtIzfwz8teUyYmd2DqslTjrvjLrE= +github.com/hairyhenderson/gomplate/v3 v3.11.8 h1:T63wLRk+Y9C601ChYa/+FZ30XT/UEWydMDZhOOJM3K0= +github.com/hairyhenderson/gomplate/v3 v3.11.8/go.mod h1:xs1LnI1NftnB6o0Zvy1aLgDMSGUvGjz4uCQAZSIMP04= github.com/hairyhenderson/toml v0.4.2-0.20210923231440-40456b8e66cf h1:I1sbT4ZbIt9i+hB1zfKw2mE8C12TuGxPiW7YmtLbPa4= github.com/hairyhenderson/toml v0.4.2-0.20210923231440-40456b8e66cf/go.mod h1:jDHmWDKZY6MIIYltYYfW4Rs7hQ50oS4qf/6spSiZAxY= github.com/hairyhenderson/yaml v0.0.0-20220618171115-2d35fca545ce h1:cVkYhlWAxwuS2/Yp6qPtcl0fGpcWxuZNonywHZ6/I+s= @@ -860,8 +860,8 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t github.com/zealic/xignore v0.3.3 h1:EpLXUgZY/JEzFkTc+Y/VYypzXtNz+MSOMVCGW5Q4CKQ= github.com/zealic/xignore v0.3.3/go.mod h1:lhS8V7fuSOtJOKsvKI7WfsZE276/7AYEqokv3UiqEAU= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= -go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= -go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= +go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0= +go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ= go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= @@ -925,8 +925,8 @@ golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1026,8 +1026,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1065,8 +1065,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1113,7 +1113,6 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1163,8 +1162,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1172,8 +1171,8 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1187,8 +1186,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1464,8 +1463,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From c38f24b2aa25d471a44ad1cae3638c9ce5cf42f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:58:53 +0000 Subject: [PATCH 021/154] build(deps): Bump github.com/spf13/viper from 1.18.2 to 1.19.0 Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.18.2 to 1.19.0. - [Release notes](https://github.com/spf13/viper/releases) - [Commits](https://github.com/spf13/viper/compare/v1.18.2...v1.19.0) --- updated-dependencies: - dependency-name: github.com/spf13/viper dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 8 ++++---- go.sum | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index eb795bfc50..ab3c7712e7 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/prometheus/exporter-toolkit v0.11.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.0 - github.com/spf13/viper v1.18.2 + github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.30.1 @@ -60,7 +60,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect - github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/procfs v0.12.0 // indirect @@ -76,12 +76,12 @@ require ( golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.18.0 // indirect - golang.org/x/sync v0.5.0 // indirect + golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - google.golang.org/appengine v1.6.7 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.34.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 9f1ae09d34..d086df54cc 100644 --- a/go.sum +++ b/go.sum @@ -41,11 +41,13 @@ github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnD github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -98,8 +100,8 @@ github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= github.com/onsi/gomega v1.31.0 h1:54UJxxj6cPInHS3a35wm6BK/F9nHYueZ1NVujHDrnXE= github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= -github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= -github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -134,11 +136,12 @@ github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= -github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -150,22 +153,26 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= @@ -173,18 +180,26 @@ golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= @@ -193,14 +208,17 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 738e6befaeebfc766b0fd62000ca777f5c4f189d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Tue, 4 Jun 2024 19:46:49 +0200 Subject: [PATCH 022/154] Add SSF Best practices badge and community section --- README.md | 14 ++++++++++++++ README.md.tpl | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/README.md b/README.md index fbebaaf9fc..d209745892 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/kubernetes/kube-state-metrics)](https://goreportcard.com/report/github.com/kubernetes/kube-state-metrics) [![Go Reference](https://pkg.go.dev/badge/github.com/kubernetes/kube-state-metrics.svg)](https://pkg.go.dev/github.com/kubernetes/kube-state-metrics) [![govulncheck](https://github.com/kubernetes/kube-state-metrics/actions/workflows/govulncheck.yml/badge.svg)](https://github.com/kubernetes/kube-state-metrics/actions/workflows/govulncheck.yml) +[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8696/badge)](https://www.bestpractices.dev/projects/8696) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/kubernetes/kube-state-metrics/badge)](https://api.securityscorecards.dev/projects/github.com/kubernetes/kube-state-metrics) kube-state-metrics (KSM) is a simple service that listens to the Kubernetes API @@ -59,6 +60,7 @@ are deleted they are no longer visible on the `/metrics` endpoint. * [Helm Chart](#helm-chart) * [Development](#development) * [Developer Contributions](#developer-contributions) + * [Community](#community) ### Versioning @@ -412,3 +414,15 @@ To run the e2e tests locally see the documentation in [tests/README.md](./tests/ #### Developer Contributions When developing, there are certain code patterns to follow to better your contributing experience and likelihood of e2e and other ci tests to pass. To learn more about them, see the documentation in [docs/developer/guide.md](./docs/developer/guide.md). + +#### Community + +This project is sponsored by [SIG Instrumentation](https://github.com/kubernetes/community/tree/master/sig-instrumentation). + +There is also a channel for [#kube-state-metrics](https://kubernetes.slack.com/archives/CJJ529RUY) on Kubernetes' Slack. + +You can also join the SIG Instrumentation [mailing list](https://groups.google.com/forum/#!forum/kubernetes-sig-instrumentation). +This will typically add invites for the following meetings to your calendar, in which topics around kube-state-metrics can be discussed. + +* Regular SIG Meeting: [Thursdays at 9:30 PT (Pacific Time)](https://zoom.us/j/5342565819?pwd=RlVsK21NVnR1dmE3SWZQSXhveHZPdz09) (biweekly). [Convert to your timezone](http://www.thetimezoneconverter.com/?t=9:30&tz=PT%20%28Pacific%20Time%29). +* Regular Triage Meeting: [Thursdays at 9:30 PT (Pacific Time)](https://zoom.us/j/5342565819?pwd=RlVsK21NVnR1dmE3SWZQSXhveHZPdz09) (biweekly - alternating with regular meeting). [Convert to your timezone](http://www.thetimezoneconverter.com/?t=9:30&tz=PT%20%28Pacific%20Time%29). diff --git a/README.md.tpl b/README.md.tpl index 932b186c12..5b659bcba1 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -4,6 +4,7 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/kubernetes/kube-state-metrics)](https://goreportcard.com/report/github.com/kubernetes/kube-state-metrics) [![Go Reference](https://pkg.go.dev/badge/github.com/kubernetes/kube-state-metrics.svg)](https://pkg.go.dev/github.com/kubernetes/kube-state-metrics) [![govulncheck](https://github.com/kubernetes/kube-state-metrics/actions/workflows/govulncheck.yml/badge.svg)](https://github.com/kubernetes/kube-state-metrics/actions/workflows/govulncheck.yml) +[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8696/badge)](https://www.bestpractices.dev/projects/8696) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/kubernetes/kube-state-metrics/badge)](https://api.securityscorecards.dev/projects/github.com/kubernetes/kube-state-metrics) kube-state-metrics (KSM) is a simple service that listens to the Kubernetes API @@ -59,6 +60,7 @@ are deleted they are no longer visible on the `/metrics` endpoint. * [Helm Chart](#helm-chart) * [Development](#development) * [Developer Contributions](#developer-contributions) + * [Community](#community) ### Versioning @@ -413,3 +415,15 @@ To run the e2e tests locally see the documentation in [tests/README.md](./tests/ #### Developer Contributions When developing, there are certain code patterns to follow to better your contributing experience and likelihood of e2e and other ci tests to pass. To learn more about them, see the documentation in [docs/developer/guide.md](./docs/developer/guide.md). + +#### Community + +This project is sponsored by [SIG Instrumentation](https://github.com/kubernetes/community/tree/master/sig-instrumentation). + +There is also a channel for [#kube-state-metrics](https://kubernetes.slack.com/archives/CJJ529RUY) on Kubernetes' Slack. + +You can also join the SIG Instrumentation [mailing list](https://groups.google.com/forum/#!forum/kubernetes-sig-instrumentation). +This will typically add invites for the following meetings to your calendar, in which topics around kube-state-metrics can be discussed. + +* Regular SIG Meeting: [Thursdays at 9:30 PT (Pacific Time)](https://zoom.us/j/5342565819?pwd=RlVsK21NVnR1dmE3SWZQSXhveHZPdz09) (biweekly). [Convert to your timezone](http://www.thetimezoneconverter.com/?t=9:30&tz=PT%20%28Pacific%20Time%29). +* Regular Triage Meeting: [Thursdays at 9:30 PT (Pacific Time)](https://zoom.us/j/5342565819?pwd=RlVsK21NVnR1dmE3SWZQSXhveHZPdz09) (biweekly - alternating with regular meeting). [Convert to your timezone](http://www.thetimezoneconverter.com/?t=9:30&tz=PT%20%28Pacific%20Time%29). From e97933bcb9f41a44cdb21f1c8812d5c22e357d36 Mon Sep 17 00:00:00 2001 From: pokom Date: Wed, 5 Jun 2024 14:18:43 -0400 Subject: [PATCH 023/154] fix(server): Add read and write timeouts There are a few documented scenarios where `kube-state-metrics` will lock up(#995, #1028). I believe a much simpler solution to ensure `kube-state-metrics` doesn't lock up and require a restart to server `/metrics` requests is to add default read and write timeouts and to allow them to be configurable. At Grafana, we've experienced a few scenarios where `kube-state-metrics` running in larger clusters falls behind and starts getting scraped multiple times. When this occurs, `kube-state-metrics` becomes completely unresponsive and requires a reboot. This is somewhat easily reproduceable(I'll provide a script in an issue) and causes other critical workloads(KEDA, VPA) to fail in weird ways. Adds two flags: - `server-read-timeout` - `server-write-timeout` Updates the metrics http server to set the `ReadTimeout` and `WriteTimeout` to the configured values. --- docs/developer/cli-arguments.md | 2 ++ pkg/app/server.go | 3 ++- pkg/options/options.go | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index 1918a7e4e8..82a2a1f3d7 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -67,6 +67,8 @@ Flags: --pod-namespace string Name of the namespace of the pod specified by --pod. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice. --port int Port to expose metrics on. (default 8080) --resources string Comma-separated list of Resources to be enabled. Defaults to "certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments" + --server-read-timeout duration The maximum duration for reading the entire request, including the body. (default 30s) + --server-write-timeout duration The maximum duration before timing out writes of the response. (default 1m0s) --shard int32 The instances shard nominal (zero indexed) within the total number of shards. (default 0) --skip_headers If true, avoid header prefixes in the log messages --skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true) diff --git a/pkg/app/server.go b/pkg/app/server.go index aa5b2c916c..c079498460 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -326,6 +326,8 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { metricsServer := http.Server{ Handler: metricsMux, ReadHeaderTimeout: 5 * time.Second, + ReadTimeout: opts.ServerReadTimeout, + WriteTimeout: opts.ServerWriteTimeout, } metricsFlags := web.FlagConfig{ WebListenAddresses: &[]string{metricsServerListenAddress}, @@ -401,7 +403,6 @@ func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prome mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace)) mux.Handle(metricsPath, promhttp.InstrumentHandlerDuration(durationObserver, m)) - // Add healthzPath mux.HandleFunc(healthzPath, func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) diff --git a/pkg/options/options.go b/pkg/options/options.go index 09adf8939a..f8c707510f 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -21,6 +21,7 @@ import ( "fmt" "os" "strings" + "time" "github.com/prometheus/common/version" "github.com/spf13/cobra" @@ -55,6 +56,8 @@ type Options struct { TelemetryPort int `yaml:"telemetry_port"` TotalShards int `yaml:"total_shards"` UseAPIServerCache bool `yaml:"use_api_server_cache"` + ServerReadTimeout time.Duration `yaml:"server_read_timeout"` + ServerWriteTimeout time.Duration `yaml:"server_write_timeout"` Config string @@ -146,6 +149,8 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().Var(&o.Namespaces, "namespaces", fmt.Sprintf("Comma-separated list of namespaces to be enabled. Defaults to %q", &DefaultNamespaces)) o.cmd.Flags().Var(&o.NamespacesDenylist, "namespaces-denylist", "Comma-separated list of namespaces not to be enabled. If namespaces and namespaces-denylist are both set, only namespaces that are excluded in namespaces-denylist will be used.") o.cmd.Flags().Var(&o.Resources, "resources", fmt.Sprintf("Comma-separated list of Resources to be enabled. Defaults to %q", &DefaultResources)) + o.cmd.Flags().DurationVar(&o.ServerReadTimeout, "server-read-timeout", 30*time.Second, "The maximum duration for reading the entire request, including the body.") + o.cmd.Flags().DurationVar(&o.ServerWriteTimeout, "server-write-timeout", 60*time.Second, "The maximum duration before timing out writes of the response.") } // Parse parses the flag definitions from the argument list. From b4f032ecfdf60953ec193754696152d19a1d8887 Mon Sep 17 00:00:00 2001 From: pokom Date: Thu, 6 Jun 2024 13:11:00 -0400 Subject: [PATCH 024/154] Add additional flags for IdleTimeouts --- docs/developer/cli-arguments.md | 2 ++ pkg/app/server.go | 3 ++- pkg/options/options.go | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index 82a2a1f3d7..817cb8b375 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -67,6 +67,8 @@ Flags: --pod-namespace string Name of the namespace of the pod specified by --pod. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice. --port int Port to expose metrics on. (default 8080) --resources string Comma-separated list of Resources to be enabled. Defaults to "certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments" + --server-idle-timeout duration The maximum amount of time to wait for the next request when keep-alives are enabled. (default 5m0s) + --server-read-header-timeout duration The maximum duration for reading the header of requests. (default 5s) --server-read-timeout duration The maximum duration for reading the entire request, including the body. (default 30s) --server-write-timeout duration The maximum duration before timing out writes of the response. (default 1m0s) --shard int32 The instances shard nominal (zero indexed) within the total number of shards. (default 0) diff --git a/pkg/app/server.go b/pkg/app/server.go index c079498460..3efd97b354 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -325,9 +325,10 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { metricsServerListenAddress := net.JoinHostPort(opts.Host, strconv.Itoa(opts.Port)) metricsServer := http.Server{ Handler: metricsMux, - ReadHeaderTimeout: 5 * time.Second, + ReadHeaderTimeout: opts.ServerReadHeaderTimeout, ReadTimeout: opts.ServerReadTimeout, WriteTimeout: opts.ServerWriteTimeout, + IdleTimeout: opts.ServerIdleTimeout, } metricsFlags := web.FlagConfig{ WebListenAddresses: &[]string{metricsServerListenAddress}, diff --git a/pkg/options/options.go b/pkg/options/options.go index f8c707510f..5d279d6f52 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -58,6 +58,8 @@ type Options struct { UseAPIServerCache bool `yaml:"use_api_server_cache"` ServerReadTimeout time.Duration `yaml:"server_read_timeout"` ServerWriteTimeout time.Duration `yaml:"server_write_timeout"` + ServerIdleTimeout time.Duration `yaml:"server_idle_timeout"` + ServerReadHeaderTimeout time.Duration `yaml:"server_read_header_timeout"` Config string @@ -149,8 +151,11 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().Var(&o.Namespaces, "namespaces", fmt.Sprintf("Comma-separated list of namespaces to be enabled. Defaults to %q", &DefaultNamespaces)) o.cmd.Flags().Var(&o.NamespacesDenylist, "namespaces-denylist", "Comma-separated list of namespaces not to be enabled. If namespaces and namespaces-denylist are both set, only namespaces that are excluded in namespaces-denylist will be used.") o.cmd.Flags().Var(&o.Resources, "resources", fmt.Sprintf("Comma-separated list of Resources to be enabled. Defaults to %q", &DefaultResources)) + o.cmd.Flags().DurationVar(&o.ServerReadTimeout, "server-read-timeout", 30*time.Second, "The maximum duration for reading the entire request, including the body.") o.cmd.Flags().DurationVar(&o.ServerWriteTimeout, "server-write-timeout", 60*time.Second, "The maximum duration before timing out writes of the response.") + o.cmd.Flags().DurationVar(&o.ServerIdleTimeout, "server-idle-timeout", 5*time.Minute, "The maximum amount of time to wait for the next request when keep-alives are enabled.") + o.cmd.Flags().DurationVar(&o.ServerReadHeaderTimeout, "server-read-header-timeout", 5*time.Second, "The maximum duration for reading the header of requests.") } // Parse parses the flag definitions from the argument list. From 28dbd26540485c8d8f7a6009193e69a7596b25f0 Mon Sep 17 00:00:00 2001 From: pokom Date: Fri, 7 Jun 2024 13:14:57 -0400 Subject: [PATCH 025/154] Create variables for default values of new flags --- pkg/options/options.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/options/options.go b/pkg/options/options.go index 5d279d6f52..f537e077c7 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -28,6 +28,16 @@ import ( "k8s.io/klog/v2" ) +var ( + // Align with the default scrape interval from Prometheus: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config + defaultServerReadTimeout = 60 * time.Second + defaultServerWriteTimeout = 60 * time.Second + // ServerIdleTimeout is set to 5 minutes to match the default idle timeout of Prometheus scrape clients + // https://github.com/prometheus/common/blob/318309999517402ad522877ac7e55fa650a11114/config/http_config.go#L55 + defaultServerIdleTimeout = 5 * time.Minute + defaultServerReadHeaderTimeout = 5 * time.Second +) + // Options are the configurable parameters for kube-state-metrics. type Options struct { AnnotationsAllowList LabelsAllowList `yaml:"annotations_allow_list"` @@ -152,10 +162,10 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().Var(&o.NamespacesDenylist, "namespaces-denylist", "Comma-separated list of namespaces not to be enabled. If namespaces and namespaces-denylist are both set, only namespaces that are excluded in namespaces-denylist will be used.") o.cmd.Flags().Var(&o.Resources, "resources", fmt.Sprintf("Comma-separated list of Resources to be enabled. Defaults to %q", &DefaultResources)) - o.cmd.Flags().DurationVar(&o.ServerReadTimeout, "server-read-timeout", 30*time.Second, "The maximum duration for reading the entire request, including the body.") - o.cmd.Flags().DurationVar(&o.ServerWriteTimeout, "server-write-timeout", 60*time.Second, "The maximum duration before timing out writes of the response.") - o.cmd.Flags().DurationVar(&o.ServerIdleTimeout, "server-idle-timeout", 5*time.Minute, "The maximum amount of time to wait for the next request when keep-alives are enabled.") - o.cmd.Flags().DurationVar(&o.ServerReadHeaderTimeout, "server-read-header-timeout", 5*time.Second, "The maximum duration for reading the header of requests.") + o.cmd.Flags().DurationVar(&o.ServerReadTimeout, "server-read-timeout", defaultServerReadTimeout, "The maximum duration for reading the entire request, including the body. Align with the scrape interval or timeout of scraping clients. ") + o.cmd.Flags().DurationVar(&o.ServerWriteTimeout, "server-write-timeout", defaultServerWriteTimeout, "The maximum duration before timing out writes of the response. Align with the scrape interval or timeout of scraping clients..") + o.cmd.Flags().DurationVar(&o.ServerIdleTimeout, "server-idle-timeout", defaultServerIdleTimeout, "The maximum amount of time to wait for the next request when keep-alives are enabled. Align with the idletimeout of your scrape clients.") + o.cmd.Flags().DurationVar(&o.ServerReadHeaderTimeout, "server-read-header-timeout", defaultServerReadHeaderTimeout, "The maximum duration for reading the header of requests.") } // Parse parses the flag definitions from the argument list. From ee3913967e6ccffbb482ad477fdd17972d48509e Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 7 Jun 2024 14:13:44 -0400 Subject: [PATCH 026/154] Update docs/developer/cli-arguments.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Manuel Rüger --- docs/developer/cli-arguments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index 817cb8b375..aca2697e64 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -69,7 +69,7 @@ Flags: --resources string Comma-separated list of Resources to be enabled. Defaults to "certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments" --server-idle-timeout duration The maximum amount of time to wait for the next request when keep-alives are enabled. (default 5m0s) --server-read-header-timeout duration The maximum duration for reading the header of requests. (default 5s) - --server-read-timeout duration The maximum duration for reading the entire request, including the body. (default 30s) + --server-read-timeout duration The maximum duration for reading the entire request, including the body. (default 1m0s) --server-write-timeout duration The maximum duration before timing out writes of the response. (default 1m0s) --shard int32 The instances shard nominal (zero indexed) within the total number of shards. (default 0) --skip_headers If true, avoid header prefixes in the log messages From 698f76a8d504bf0b369e3a5c22fa76c19a0c833c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:01:12 +0000 Subject: [PATCH 027/154] build(deps): Bump github.com/prometheus/common from 0.53.0 to 0.54.0 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.53.0 to 0.54.0. - [Release notes](https://github.com/prometheus/common/releases) - [Changelog](https://github.com/prometheus/common/blob/main/RELEASE.md) - [Commits](https://github.com/prometheus/common/compare/v0.53.0...v0.54.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 9 ++++----- go.sum | 38 ++++++++------------------------------ 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index ab3c7712e7..027a8a210d 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.19.1 github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common v0.53.0 + github.com/prometheus/common v0.54.0 github.com/prometheus/exporter-toolkit v0.11.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.0 @@ -72,16 +72,15 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.21.0 // indirect + golang.org/x/crypto v0.22.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/oauth2 v0.18.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/oauth2 v0.19.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.34.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index d086df54cc..64958087c6 100644 --- a/go.sum +++ b/go.sum @@ -41,13 +41,10 @@ github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnD github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -111,8 +108,8 @@ github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQ github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= -github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= +github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM1D8= +github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= @@ -153,53 +150,39 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= +golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= @@ -208,17 +191,12 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From cd460fef2901206b455f5b8562e789f736e59902 Mon Sep 17 00:00:00 2001 From: pokom Date: Tue, 11 Jun 2024 06:48:22 -0400 Subject: [PATCH 028/154] Update cli-arguments.md --- docs/developer/cli-arguments.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index aca2697e64..6648c72278 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -67,10 +67,10 @@ Flags: --pod-namespace string Name of the namespace of the pod specified by --pod. When set, it is expected that --pod and --pod-namespace are both set. Most likely this should be passed via the downward API. This is used for auto-detecting sharding. If set, this has preference over statically configured sharding. This is experimental, it may be removed without notice. --port int Port to expose metrics on. (default 8080) --resources string Comma-separated list of Resources to be enabled. Defaults to "certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments" - --server-idle-timeout duration The maximum amount of time to wait for the next request when keep-alives are enabled. (default 5m0s) + --server-idle-timeout duration The maximum amount of time to wait for the next request when keep-alives are enabled. Align with the idletimeout of your scrape clients. (default 5m0s) --server-read-header-timeout duration The maximum duration for reading the header of requests. (default 5s) - --server-read-timeout duration The maximum duration for reading the entire request, including the body. (default 1m0s) - --server-write-timeout duration The maximum duration before timing out writes of the response. (default 1m0s) + --server-read-timeout duration The maximum duration for reading the entire request, including the body. Align with the scrape interval or timeout of scraping clients. (default 1m0s) + --server-write-timeout duration The maximum duration before timing out writes of the response. Align with the scrape interval or timeout of scraping clients.. (default 1m0s) --shard int32 The instances shard nominal (zero indexed) within the total number of shards. (default 0) --skip_headers If true, avoid header prefixes in the log messages --skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true) From 8760088b4929528e3d9cea0392cf1d1660c2bad7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:12:42 +0000 Subject: [PATCH 029/154] build(deps): Bump the k8s-dependencies group with 6 updates Bumps the k8s-dependencies group with 6 updates: | Package | From | To | | --- | --- | --- | | [k8s.io/api](https://github.com/kubernetes/api) | `0.30.1` | `0.30.2` | | [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) | `0.30.1` | `0.30.2` | | [k8s.io/client-go](https://github.com/kubernetes/client-go) | `0.30.1` | `0.30.2` | | [k8s.io/component-base](https://github.com/kubernetes/component-base) | `0.30.1` | `0.30.2` | | [k8s.io/klog/v2](https://github.com/kubernetes/klog) | `2.120.1` | `2.130.0` | | [k8s.io/sample-controller](https://github.com/kubernetes/sample-controller) | `0.30.1` | `0.30.2` | Updates `k8s.io/api` from 0.30.1 to 0.30.2 - [Commits](https://github.com/kubernetes/api/compare/v0.30.1...v0.30.2) Updates `k8s.io/apimachinery` from 0.30.1 to 0.30.2 - [Commits](https://github.com/kubernetes/apimachinery/compare/v0.30.1...v0.30.2) Updates `k8s.io/client-go` from 0.30.1 to 0.30.2 - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes/client-go/compare/v0.30.1...v0.30.2) Updates `k8s.io/component-base` from 0.30.1 to 0.30.2 - [Commits](https://github.com/kubernetes/component-base/compare/v0.30.1...v0.30.2) Updates `k8s.io/klog/v2` from 2.120.1 to 2.130.0 - [Release notes](https://github.com/kubernetes/klog/releases) - [Changelog](https://github.com/kubernetes/klog/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes/klog/compare/v2.120.1...v2.130.0) Updates `k8s.io/sample-controller` from 0.30.1 to 0.30.2 - [Commits](https://github.com/kubernetes/sample-controller/compare/v0.30.1...v0.30.2) --- updated-dependencies: - dependency-name: k8s.io/api dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/apimachinery dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/client-go dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/component-base dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/klog/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: k8s-dependencies - dependency-name: k8s.io/sample-controller dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] --- go.mod | 12 ++++++------ go.sum | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 027a8a210d..8302736649 100644 --- a/go.mod +++ b/go.mod @@ -19,12 +19,12 @@ require ( github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.30.1 - k8s.io/apimachinery v0.30.1 - k8s.io/client-go v0.30.1 - k8s.io/component-base v0.30.1 - k8s.io/klog/v2 v2.120.1 - k8s.io/sample-controller v0.30.1 + k8s.io/api v0.30.2 + k8s.io/apimachinery v0.30.2 + k8s.io/client-go v0.30.2 + k8s.io/component-base v0.30.2 + k8s.io/klog/v2 v2.130.0 + k8s.io/sample-controller v0.30.2 k8s.io/utils v0.0.0-20240310230437-4693a0247e57 ) diff --git a/go.sum b/go.sum index 64958087c6..ff601fd853 100644 --- a/go.sum +++ b/go.sum @@ -212,20 +212,20 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.30.1 h1:kCm/6mADMdbAxmIh0LBjS54nQBE+U4KmbCfIkF5CpJY= -k8s.io/api v0.30.1/go.mod h1:ddbN2C0+0DIiPntan/bye3SW3PdwLa11/0yqwvuRrJM= -k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U= -k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/client-go v0.30.1 h1:uC/Ir6A3R46wdkgCV3vbLyNOYyCJ8oZnjtJGKfytl/Q= -k8s.io/client-go v0.30.1/go.mod h1:wrAqLNs2trwiCH/wxxmT/x3hKVH9PuV0GGW0oDoHVqc= -k8s.io/component-base v0.30.1 h1:bvAtlPh1UrdaZL20D9+sWxsJljMi0QZ3Lmw+kmZAaxQ= -k8s.io/component-base v0.30.1/go.mod h1:e/X9kDiOebwlI41AvBHuWdqFriSRrX50CdwA9TFaHLI= -k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= -k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI= +k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI= +k8s.io/apimachinery v0.30.2 h1:fEMcnBj6qkzzPGSVsAZtQThU62SmQ4ZymlXRC5yFSCg= +k8s.io/apimachinery v0.30.2/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50= +k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs= +k8s.io/component-base v0.30.2 h1:pqGBczYoW1sno8q9ObExUqrYSKhtE5rW3y6gX88GZII= +k8s.io/component-base v0.30.2/go.mod h1:yQLkQDrkK8J6NtP+MGJOws+/PPeEXNpwFixsUI7h/OE= +k8s.io/klog/v2 v2.130.0 h1:5nB3+3HpqKqXJIXNtJdtxcDCfaa9KL8StJgMzGJkUkM= +k8s.io/klog/v2 v2.130.0/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= -k8s.io/sample-controller v0.30.1 h1:X5MElr3bSf6Fe5k483EyM8RkeEdPEqheMU8rkjS1wYc= -k8s.io/sample-controller v0.30.1/go.mod h1:AagDyBDgEb7nXTFJXyWDDz/XPWmtq+ly02EPMpHicPQ= +k8s.io/sample-controller v0.30.2 h1:J8Xvli+YHS6C7sWFzn00N2CAtkvLOguXj+Iq4S3oMwA= +k8s.io/sample-controller v0.30.2/go.mod h1:Btgcc0ZQfurowzwy4e7v3wx4hE1AADwzhZ+apsJ4J8Y= k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY= k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= From 9f61037781b4ac23a2b80699473e8f3675b3d18d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:12:47 +0000 Subject: [PATCH 030/154] build(deps): Bump github.com/spf13/cobra from 1.8.0 to 1.8.1 Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.8.0 to 1.8.1. - [Release notes](https://github.com/spf13/cobra/releases) - [Commits](https://github.com/spf13/cobra/compare/v1.8.0...v1.8.1) --- updated-dependencies: - dependency-name: github.com/spf13/cobra dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 027a8a210d..b31b71979e 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/prometheus/common v0.54.0 github.com/prometheus/exporter-toolkit v0.11.0 github.com/robfig/cron/v3 v3.0.1 - github.com/spf13/cobra v1.8.0 + github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 64958087c6..0ce1b932a2 100644 --- a/go.sum +++ b/go.sum @@ -6,7 +6,7 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -129,8 +129,8 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= From dba6d4d7e4724a995a1e66b69c6d4d64e5ed52fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:41:29 +0000 Subject: [PATCH 031/154] build(deps): Bump actions/checkout from 4.1.3 to 4.1.7 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.3 to 4.1.7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4.1.3...692973e3d937129bcbf40652eb9f2f61becf3332) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 18 +++++++++--------- .github/workflows/govulncheck.yml | 2 +- .github/workflows/openvex.yml | 2 +- .github/workflows/sbom.yaml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae055fe7df..729fbe12df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 @@ -72,7 +72,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 @@ -93,7 +93,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 @@ -114,7 +114,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 @@ -135,7 +135,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup promtool run: | @@ -150,7 +150,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 @@ -171,7 +171,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 @@ -192,7 +192,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 8d166fe997..ea10234a1f 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -15,7 +15,7 @@ jobs: ci-security-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 name: Checkout code - name: Set up Go 1.x uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index 113dbb1b75..b3384578ea 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set environment variables run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - uses: openvex/generate-vex@c59881b41451d7ccba5c3b74cd195382b8971fcd diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index ea82cb0125..d3ca1e3ebd 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -21,7 +21,7 @@ jobs: steps: - name: Fetch source code into GITHUB_WORKSPACE - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Kubernetes BOM uses: kubernetes-sigs/release-actions/setup-bom@841d76a188a7c121231a863572e27012805715a2 # v0.1.4 From 5ac3eff94bb7fa5ba41102c10e59ce1d5a935ca8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:26:19 +0000 Subject: [PATCH 032/154] build(deps): Bump kubernetes-sigs/release-actions from 0.1.4 to 0.2.0 Bumps [kubernetes-sigs/release-actions](https://github.com/kubernetes-sigs/release-actions) from 0.1.4 to 0.2.0. - [Release notes](https://github.com/kubernetes-sigs/release-actions/releases) - [Changelog](https://github.com/kubernetes-sigs/release-actions/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes-sigs/release-actions/compare/841d76a188a7c121231a863572e27012805715a2...2f8b9ec22aedc9ce15039b6c7716aa6c2907df1c) --- updated-dependencies: - dependency-name: kubernetes-sigs/release-actions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/sbom.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index d3ca1e3ebd..73949a0204 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Kubernetes BOM - uses: kubernetes-sigs/release-actions/setup-bom@841d76a188a7c121231a863572e27012805715a2 # v0.1.4 + uses: kubernetes-sigs/release-actions/setup-bom@2f8b9ec22aedc9ce15039b6c7716aa6c2907df1c # v0.2.0 - name: Generate SBOM run: | From 9dfddac86acb24321a4bfcc279bc758fa5419ac7 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Thu, 23 May 2024 17:05:37 +0100 Subject: [PATCH 033/154] Publish OpenVEX data on release Signed-off-by: Ricardo Lopes --- .github/workflows/openvex.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index b3384578ea..320fcefa97 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -16,8 +16,16 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set environment variables run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - uses: openvex/generate-vex@c59881b41451d7ccba5c3b74cd195382b8971fcd # Refer: https://github.com/openvex/vexctl#operational-model name: Run vexctl with: product: pkg:golang/k8s.io/kube-state-metrics/v2@${{ env.RELEASE_VERSION }} + file: kube-state-metrics.openvex.json + + - name: Upload OpenVEX document to GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload ${{ env.RELEASE_VERSION }} kube-state-metrics.openvex.json From 2bd0b60b5a9b8b605cb1168a9e787f88ac3b928b Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Thu, 23 May 2024 17:07:13 +0100 Subject: [PATCH 034/154] Avoid trigger OpenVEX on pre-release Signed-off-by: Ricardo Lopes --- .github/workflows/openvex.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index 320fcefa97..6819e3c49e 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -3,7 +3,8 @@ name: openvex on: workflow_dispatch: release: - types: [published] + types: + - released permissions: contents: read From fba4a75753bcbdd59296d0456a15f5fc9c6839e4 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Mon, 17 Jun 2024 09:32:20 +0100 Subject: [PATCH 035/154] Fix permissions for uploading to release Signed-off-by: Ricardo Lopes --- .github/workflows/openvex.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index 6819e3c49e..e37b274b96 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -12,6 +12,10 @@ permissions: jobs: vexctl: runs-on: ubuntu-latest + + permissions: + contents: write + steps: - name: Checkout code uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 From 4269ab10ab92cd9b40a2d3bd7d977d692fac37ca Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Mon, 17 Jun 2024 09:32:57 +0100 Subject: [PATCH 036/154] Apply consistent format across workflow files Signed-off-by: Ricardo Lopes --- .github/workflows/openvex.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index e37b274b96..5b80fa92b2 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -19,6 +19,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Set environment variables run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV @@ -33,4 +34,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh release upload ${{ env.RELEASE_VERSION }} kube-state-metrics.openvex.json + gh release upload ${{ env.RELEASE_VERSION }} kube-state-metrics.openvex.json From 1483f22ce4e87c4b8d79245ea1acad61c039e077 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:54:21 +0000 Subject: [PATCH 037/154] build(deps): Bump k8s.io/klog/v2 in the k8s-dependencies group Bumps the k8s-dependencies group with 1 update: [k8s.io/klog/v2](https://github.com/kubernetes/klog). Updates `k8s.io/klog/v2` from 2.130.0 to 2.130.1 - [Release notes](https://github.com/kubernetes/klog/releases) - [Changelog](https://github.com/kubernetes/klog/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes/klog/compare/v2.130.0...v2.130.1) --- updated-dependencies: - dependency-name: k8s.io/klog/v2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0f5dee6443..812e909966 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( k8s.io/apimachinery v0.30.2 k8s.io/client-go v0.30.2 k8s.io/component-base v0.30.2 - k8s.io/klog/v2 v2.130.0 + k8s.io/klog/v2 v2.130.1 k8s.io/sample-controller v0.30.2 k8s.io/utils v0.0.0-20240310230437-4693a0247e57 ) diff --git a/go.sum b/go.sum index 8c4b7933e6..676d3a64d5 100644 --- a/go.sum +++ b/go.sum @@ -220,8 +220,8 @@ k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50= k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs= k8s.io/component-base v0.30.2 h1:pqGBczYoW1sno8q9ObExUqrYSKhtE5rW3y6gX88GZII= k8s.io/component-base v0.30.2/go.mod h1:yQLkQDrkK8J6NtP+MGJOws+/PPeEXNpwFixsUI7h/OE= -k8s.io/klog/v2 v2.130.0 h1:5nB3+3HpqKqXJIXNtJdtxcDCfaa9KL8StJgMzGJkUkM= -k8s.io/klog/v2 v2.130.0/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/sample-controller v0.30.2 h1:J8Xvli+YHS6C7sWFzn00N2CAtkvLOguXj+Iq4S3oMwA= From eb80c097557dffff21d2bcbbc07520c400dfbf39 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Thu, 13 Jun 2024 02:45:58 +0530 Subject: [PATCH 038/154] enhancement: add `livez` endpoint Add a `livez` endpoint to identify network outages. This helps in restarting the binary if such as case is observed. Signed-off-by: Pranshu Srivastava Signed-off-by: Pranshu Srivastava --- README.md | 8 +++++ README.md.tpl | 8 +++++ examples/autosharding/statefulset.yaml | 2 +- examples/daemonsetsharding/daemonset.yaml | 2 +- .../deployment-no-node-pods.yaml | 2 +- examples/daemonsetsharding/deployment.yaml | 2 +- examples/standard/deployment.yaml | 2 +- .../kube-state-metrics.libsonnet | 2 +- pkg/app/server.go | 35 +++++++++++++++---- 9 files changed, 51 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fbebaaf9fc..e263c0dbec 100644 --- a/README.md +++ b/README.md @@ -342,6 +342,14 @@ Note that your GCP identity is case sensitive but `gcloud info` as of Google Clo After running the above, if you see `Clusterrolebinding "cluster-admin-binding" created`, then you are able to continue with the setup of this service. +#### Healthcheck Endpoints + +The following healthcheck endpoints are available, some of which are used to determine the result of the aforementioned probes: + +* `/livez`: Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to use this as a liveness probe. +* `/metrics`: Returns a 200 status code if the application is able to serve metrics. While this is available for both ports, we recommend to use the telemetry metrics endpoint as a readiness probe. +* `/healthz`: Returns a 200 status code if the application is running. We recommend to use this as a startup probe. + #### Limited privileges environment If you want to run kube-state-metrics in an environment where you don't have cluster-reader role, you can: diff --git a/README.md.tpl b/README.md.tpl index 932b186c12..66bfe837ba 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -343,6 +343,14 @@ Note that your GCP identity is case sensitive but `gcloud info` as of Google Clo After running the above, if you see `Clusterrolebinding "cluster-admin-binding" created`, then you are able to continue with the setup of this service. +#### Healthcheck Endpoints + +The following healthcheck endpoints are available, some of which are used to determine the result of the aforementioned probes: + +* `/livez`: Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to use this as a liveness probe. +* `/metrics`: Returns a 200 status code if the application is able to serve metrics. While this is available for both ports, we recommend to use the telemetry metrics endpoint as a readiness probe. +* `/healthz`: Returns a 200 status code if the application is running. We recommend to use this as a startup probe. + #### Limited privileges environment If you want to run kube-state-metrics in an environment where you don't have cluster-reader role, you can: diff --git a/examples/autosharding/statefulset.yaml b/examples/autosharding/statefulset.yaml index 37dd37153f..cc12a09152 100644 --- a/examples/autosharding/statefulset.yaml +++ b/examples/autosharding/statefulset.yaml @@ -37,7 +37,7 @@ spec: image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 livenessProbe: httpGet: - path: /healthz + path: /livez port: 8080 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/examples/daemonsetsharding/daemonset.yaml b/examples/daemonsetsharding/daemonset.yaml index 7a4ea43d87..897a296848 100644 --- a/examples/daemonsetsharding/daemonset.yaml +++ b/examples/daemonsetsharding/daemonset.yaml @@ -32,7 +32,7 @@ spec: image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 livenessProbe: httpGet: - path: /healthz + path: /livez port: 8080 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index a4b4032214..c5995a30d1 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -27,7 +27,7 @@ spec: image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 livenessProbe: httpGet: - path: /healthz + path: /livez port: 8080 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/examples/daemonsetsharding/deployment.yaml b/examples/daemonsetsharding/deployment.yaml index cbd6d7dd8d..2973ddc2fb 100644 --- a/examples/daemonsetsharding/deployment.yaml +++ b/examples/daemonsetsharding/deployment.yaml @@ -26,7 +26,7 @@ spec: image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 livenessProbe: httpGet: - path: /healthz + path: /livez port: 8080 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/examples/standard/deployment.yaml b/examples/standard/deployment.yaml index 85c3cec3e4..3f6ce8bc21 100644 --- a/examples/standard/deployment.yaml +++ b/examples/standard/deployment.yaml @@ -24,7 +24,7 @@ spec: - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 livenessProbe: httpGet: - path: /healthz + path: /livez port: 8080 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index a7c2904123..e392152dfe 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -193,7 +193,7 @@ }, livenessProbe: { timeoutSeconds: 5, initialDelaySeconds: 5, httpGet: { port: 8080, - path: '/healthz', + path: '/livez', } }, readinessProbe: { timeoutSeconds: 5, initialDelaySeconds: 5, httpGet: { port: 8081, diff --git a/pkg/app/server.go b/pkg/app/server.go index 3efd97b354..6a7db543e5 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -30,6 +30,12 @@ import ( "strings" "time" + "gopkg.in/yaml.v3" + "k8s.io/client-go/kubernetes" + _ "k8s.io/client-go/plugin/pkg/client/auth" // Initialize common client auth plugins. + "k8s.io/client-go/tools/clientcmd" + "k8s.io/klog/v2" + "github.com/oklog/run" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/collectors" @@ -38,10 +44,6 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/version" "github.com/prometheus/exporter-toolkit/web" - "gopkg.in/yaml.v3" - _ "k8s.io/client-go/plugin/pkg/client/auth" // Initialize common client auth plugins. - "k8s.io/client-go/tools/clientcmd" - "k8s.io/klog/v2" "k8s.io/kube-state-metrics/v2/internal/discovery" "k8s.io/kube-state-metrics/v2/internal/store" @@ -59,6 +61,7 @@ import ( const ( metricsPath = "/metrics" healthzPath = "/healthz" + livezPath = "/livez" ) // promLogger implements promhttp.Logger @@ -321,7 +324,7 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { WebConfigFile: &tlsConfig, } - metricsMux := buildMetricsServer(m, durationVec) + metricsMux := buildMetricsServer(m, durationVec, kubeClient) metricsServerListenAddress := net.JoinHostPort(opts.Host, strconv.Itoa(opts.Port)) metricsServer := http.Server{ Handler: metricsMux, @@ -393,7 +396,7 @@ func buildTelemetryServer(registry prometheus.Gatherer) *http.ServeMux { return mux } -func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prometheus.ObserverVec) *http.ServeMux { +func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prometheus.ObserverVec, client kubernetes.Interface) *http.ServeMux { mux := http.NewServeMux() // TODO: This doesn't belong into serveMetrics @@ -403,7 +406,23 @@ func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prome mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol)) mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace)) + // Add metricsPath mux.Handle(metricsPath, promhttp.InstrumentHandlerDuration(durationObserver, m)) + + // Add livezPath + mux.Handle(livezPath, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + + // Query the Kube API to make sure we are not affected by a network outage. + got := client.CoreV1().RESTClient().Get().AbsPath("/livez").Do(context.Background()) + if got.Error() != nil { + w.WriteHeader(http.StatusServiceUnavailable) + w.Write([]byte(http.StatusText(http.StatusServiceUnavailable))) + return + } + w.WriteHeader(http.StatusOK) + w.Write([]byte(http.StatusText(http.StatusOK))) + })) + // Add healthzPath mux.HandleFunc(healthzPath, func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) @@ -424,6 +443,10 @@ func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prome Address: healthzPath, Text: "Healthz", }, + { + Address: livezPath, + Text: "Livez", + }, }, } landingPage, err := web.NewLandingPage(landingConfig) From 6f8f7d1f7be92178302e4f21aec59fb84ae42091 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Tue, 25 Jun 2024 15:00:20 +0530 Subject: [PATCH 039/154] fixup! enhancement: add `livez` endpoint --- examples/autosharding/statefulset.yaml | 2 +- examples/daemonsetsharding/daemonset.yaml | 2 +- examples/daemonsetsharding/deployment-no-node-pods.yaml | 2 +- examples/daemonsetsharding/deployment.yaml | 2 +- examples/standard/deployment.yaml | 2 +- jsonnet/kube-state-metrics/kube-state-metrics.libsonnet | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/autosharding/statefulset.yaml b/examples/autosharding/statefulset.yaml index cc12a09152..2b3a8e39b5 100644 --- a/examples/autosharding/statefulset.yaml +++ b/examples/autosharding/statefulset.yaml @@ -49,7 +49,7 @@ spec: name: telemetry readinessProbe: httpGet: - path: / + path: /metrics port: 8081 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/examples/daemonsetsharding/daemonset.yaml b/examples/daemonsetsharding/daemonset.yaml index 897a296848..e856c673f7 100644 --- a/examples/daemonsetsharding/daemonset.yaml +++ b/examples/daemonsetsharding/daemonset.yaml @@ -44,7 +44,7 @@ spec: name: telemetry readinessProbe: httpGet: - path: / + path: /metrics port: 8081 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index c5995a30d1..8f6e7b4482 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -39,7 +39,7 @@ spec: name: telemetry readinessProbe: httpGet: - path: / + path: /metrics port: 8081 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/examples/daemonsetsharding/deployment.yaml b/examples/daemonsetsharding/deployment.yaml index 2973ddc2fb..3b51b034d6 100644 --- a/examples/daemonsetsharding/deployment.yaml +++ b/examples/daemonsetsharding/deployment.yaml @@ -38,7 +38,7 @@ spec: name: telemetry readinessProbe: httpGet: - path: / + path: /metrics port: 8081 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/examples/standard/deployment.yaml b/examples/standard/deployment.yaml index 3f6ce8bc21..ce74e4fbf9 100644 --- a/examples/standard/deployment.yaml +++ b/examples/standard/deployment.yaml @@ -36,7 +36,7 @@ spec: name: telemetry readinessProbe: httpGet: - path: / + path: /metrics port: 8081 initialDelaySeconds: 5 timeoutSeconds: 5 diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index e392152dfe..82695482b4 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -197,7 +197,7 @@ } }, readinessProbe: { timeoutSeconds: 5, initialDelaySeconds: 5, httpGet: { port: 8081, - path: '/', + path: '/metrics', } }, }; From f6c5a4bb2c265a6fa9d588bbdfd44257b2664839 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:23:40 +0000 Subject: [PATCH 040/154] build(deps): Bump amannn/action-semantic-pull-request Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) from 5.5.2 to 5.5.3. - [Release notes](https://github.com/amannn/action-semantic-pull-request/releases) - [Changelog](https://github.com/amannn/action-semantic-pull-request/blob/main/CHANGELOG.md) - [Commits](https://github.com/amannn/action-semantic-pull-request/compare/cfb60706e18bc85e8aec535e3c577abe8f70378e...0723387faaf9b38adef4775cd42cfd5155ed6017) --- updated-dependencies: - dependency-name: amannn/action-semantic-pull-request dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/semantic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/semantic.yml b/.github/workflows/semantic.yml index 30724a98f2..ad62ec05d3 100644 --- a/.github/workflows/semantic.yml +++ b/.github/workflows/semantic.yml @@ -18,6 +18,6 @@ jobs: name: Validate PR title for semantic commit message runs-on: ubuntu-latest steps: - - uses: amannn/action-semantic-pull-request@cfb60706e18bc85e8aec535e3c577abe8f70378e # v5.5.2 + - uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d01ed2f8ded2c4569e1598746eec173b34e80f6d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:27:22 +0000 Subject: [PATCH 041/154] build(deps): Bump github.com/prometheus/common from 0.54.0 to 0.55.0 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.54.0 to 0.55.0. - [Release notes](https://github.com/prometheus/common/releases) - [Changelog](https://github.com/prometheus/common/blob/main/RELEASE.md) - [Commits](https://github.com/prometheus/common/compare/v0.54.0...v0.55.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 20 ++++++++++---------- go.sum | 44 ++++++++++++++++++++++---------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/go.mod b/go.mod index 812e909966..a3a99a8791 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.19.1 github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common v0.54.0 + github.com/prometheus/common v0.55.0 github.com/prometheus/exporter-toolkit v0.11.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.1 @@ -63,7 +63,7 @@ require ( github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect @@ -72,16 +72,16 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.22.0 // indirect + golang.org/x/crypto v0.24.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.24.0 // indirect - golang.org/x/oauth2 v0.19.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/term v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/term v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect - google.golang.org/protobuf v1.34.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 676d3a64d5..9b26002967 100644 --- a/go.sum +++ b/go.sum @@ -108,12 +108,12 @@ github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQ github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM1D8= -github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= @@ -155,8 +155,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -165,40 +165,40 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= -golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= -golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= -google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= From dae1f062c0994d724478ca8e6024e2ad366cb2a8 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Thu, 4 Jul 2024 01:08:42 +0530 Subject: [PATCH 042/154] fix: add `readyz` endpoint Discourage the usage of `/metrics` for any probe, and use `/readyz` in place of the earlier telemetry metrics endpoint to secure the exposition data. Signed-off-by: Pranshu Srivastava --- README.md | 8 +++-- README.md.tpl | 8 +++-- examples/autosharding/statefulset.yaml | 6 ++-- examples/daemonsetsharding/daemonset.yaml | 6 ++-- .../deployment-no-node-pods.yaml | 6 ++-- examples/daemonsetsharding/deployment.yaml | 6 ++-- examples/standard/deployment.yaml | 6 ++-- .../kube-state-metrics.libsonnet | 6 ++-- pkg/app/server.go | 33 ++++++++++--------- 9 files changed, 46 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index f8654e69de..8b29929216 100644 --- a/README.md +++ b/README.md @@ -348,9 +348,11 @@ After running the above, if you see `Clusterrolebinding "cluster-admin-binding" The following healthcheck endpoints are available, some of which are used to determine the result of the aforementioned probes: -* `/livez`: Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to use this as a liveness probe. -* `/metrics`: Returns a 200 status code if the application is able to serve metrics. While this is available for both ports, we recommend to use the telemetry metrics endpoint as a readiness probe. -* `/healthz`: Returns a 200 status code if the application is running. We recommend to use this as a startup probe. +* `/healthz`: Returns a 200 status code if the application is running. We recommend to use this for the startup probe. +* `/livez`: Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to using this for the liveness probe. +* `/readyz`: Returns a 200 status code if the application is ready to accept traffic. We recommend using this for the readiness probe. + +Note that it is discouraged to use the telemetry metrics endpoint for any probe when proxying the exposition data. #### Limited privileges environment diff --git a/README.md.tpl b/README.md.tpl index d5beb3b089..67facfae63 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -349,9 +349,11 @@ After running the above, if you see `Clusterrolebinding "cluster-admin-binding" The following healthcheck endpoints are available, some of which are used to determine the result of the aforementioned probes: -* `/livez`: Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to use this as a liveness probe. -* `/metrics`: Returns a 200 status code if the application is able to serve metrics. While this is available for both ports, we recommend to use the telemetry metrics endpoint as a readiness probe. -* `/healthz`: Returns a 200 status code if the application is running. We recommend to use this as a startup probe. +* `/healthz`: Returns a 200 status code if the application is running. We recommend to use this for the startup probe. +* `/livez`: Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to using this for the liveness probe. +* `/readyz`: Returns a 200 status code if the application is ready to accept traffic. We recommend using this for the readiness probe. + +Note that it is discouraged to use the telemetry metrics endpoint for any probe when proxying the exposition data. #### Limited privileges environment diff --git a/examples/autosharding/statefulset.yaml b/examples/autosharding/statefulset.yaml index 2b3a8e39b5..059832e8f8 100644 --- a/examples/autosharding/statefulset.yaml +++ b/examples/autosharding/statefulset.yaml @@ -38,7 +38,7 @@ spec: livenessProbe: httpGet: path: /livez - port: 8080 + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 name: kube-state-metrics @@ -49,8 +49,8 @@ spec: name: telemetry readinessProbe: httpGet: - path: /metrics - port: 8081 + path: /readyz + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/examples/daemonsetsharding/daemonset.yaml b/examples/daemonsetsharding/daemonset.yaml index e856c673f7..f5f8c0908c 100644 --- a/examples/daemonsetsharding/daemonset.yaml +++ b/examples/daemonsetsharding/daemonset.yaml @@ -33,7 +33,7 @@ spec: livenessProbe: httpGet: path: /livez - port: 8080 + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 name: kube-state-metrics-shard @@ -44,8 +44,8 @@ spec: name: telemetry readinessProbe: httpGet: - path: /metrics - port: 8081 + path: /readyz + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index 8f6e7b4482..dc484a61a1 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -28,7 +28,7 @@ spec: livenessProbe: httpGet: path: /livez - port: 8080 + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 name: kube-state-metrics @@ -39,8 +39,8 @@ spec: name: telemetry readinessProbe: httpGet: - path: /metrics - port: 8081 + path: /readyz + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/examples/daemonsetsharding/deployment.yaml b/examples/daemonsetsharding/deployment.yaml index 3b51b034d6..f9ad51f31a 100644 --- a/examples/daemonsetsharding/deployment.yaml +++ b/examples/daemonsetsharding/deployment.yaml @@ -27,7 +27,7 @@ spec: livenessProbe: httpGet: path: /livez - port: 8080 + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 name: kube-state-metrics @@ -38,8 +38,8 @@ spec: name: telemetry readinessProbe: httpGet: - path: /metrics - port: 8081 + path: /readyz + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/examples/standard/deployment.yaml b/examples/standard/deployment.yaml index ce74e4fbf9..b34a433774 100644 --- a/examples/standard/deployment.yaml +++ b/examples/standard/deployment.yaml @@ -25,7 +25,7 @@ spec: livenessProbe: httpGet: path: /livez - port: 8080 + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 name: kube-state-metrics @@ -36,8 +36,8 @@ spec: name: telemetry readinessProbe: httpGet: - path: /metrics - port: 8081 + path: /readyz + port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index 82695482b4..6a96112632 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -192,12 +192,12 @@ seccompProfile: { type: 'RuntimeDefault' }, }, livenessProbe: { timeoutSeconds: 5, initialDelaySeconds: 5, httpGet: { - port: 8080, + port: "http-metrics", path: '/livez', } }, readinessProbe: { timeoutSeconds: 5, initialDelaySeconds: 5, httpGet: { - port: 8081, - path: '/metrics', + port: "http-metrics", + path: '/readyz', } }, }; diff --git a/pkg/app/server.go b/pkg/app/server.go index 6a7db543e5..eee48009f8 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -62,6 +62,7 @@ const ( metricsPath = "/metrics" healthzPath = "/healthz" livezPath = "/livez" + readyzPath = "/readyz" ) // promLogger implements promhttp.Logger @@ -396,6 +397,19 @@ func buildTelemetryServer(registry prometheus.Gatherer) *http.ServeMux { return mux } +func handleClusterDelegationForProber(client kubernetes.Interface, probeType string) http.HandlerFunc { + return func(w http.ResponseWriter, _ *http.Request) { + got := client.CoreV1().RESTClient().Get().AbsPath(probeType).Do(context.Background()) + if got.Error() != nil { + w.WriteHeader(http.StatusServiceUnavailable) + w.Write([]byte(http.StatusText(http.StatusServiceUnavailable))) + return + } + w.WriteHeader(http.StatusOK) + w.Write([]byte(http.StatusText(http.StatusOK))) + } +} + func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prometheus.ObserverVec, client kubernetes.Interface) *http.ServeMux { mux := http.NewServeMux() @@ -410,24 +424,13 @@ func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prome mux.Handle(metricsPath, promhttp.InstrumentHandlerDuration(durationObserver, m)) // Add livezPath - mux.Handle(livezPath, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + mux.Handle(livezPath, handleClusterDelegationForProber(client, livezPath)) - // Query the Kube API to make sure we are not affected by a network outage. - got := client.CoreV1().RESTClient().Get().AbsPath("/livez").Do(context.Background()) - if got.Error() != nil { - w.WriteHeader(http.StatusServiceUnavailable) - w.Write([]byte(http.StatusText(http.StatusServiceUnavailable))) - return - } - w.WriteHeader(http.StatusOK) - w.Write([]byte(http.StatusText(http.StatusOK))) - })) + // Add readyzPath + mux.Handle(readyzPath, handleClusterDelegationForProber(client, readyzPath)) // Add healthzPath - mux.HandleFunc(healthzPath, func(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(http.StatusOK) - w.Write([]byte(http.StatusText(http.StatusOK))) - }) + mux.Handle(healthzPath, handleClusterDelegationForProber(client, healthzPath)) // Add index landingConfig := web.LandingConfig{ From b980579e0885b5f6fe9a6b47ff71b4da9fef647e Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Fri, 5 Jul 2024 18:27:48 +0530 Subject: [PATCH 043/154] fixup! fix: add `readyz` endpoint --- README.md | 8 ++++---- README.md.tpl | 8 ++++---- examples/autosharding/statefulset.yaml | 2 +- examples/daemonsetsharding/daemonset.yaml | 2 +- .../deployment-no-node-pods.yaml | 2 +- examples/daemonsetsharding/deployment.yaml | 2 +- examples/standard/deployment.yaml | 2 +- .../kube-state-metrics.libsonnet | 2 +- pkg/app/server.go | 16 +++++++++++++--- 9 files changed, 27 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 8b29929216..58dbf31b5a 100644 --- a/README.md +++ b/README.md @@ -346,11 +346,11 @@ After running the above, if you see `Clusterrolebinding "cluster-admin-binding" #### Healthcheck Endpoints -The following healthcheck endpoints are available, some of which are used to determine the result of the aforementioned probes: +The following healthcheck endpoints are available (`self` refers to the telemetry port, while `main` refers to the exposition port): -* `/healthz`: Returns a 200 status code if the application is running. We recommend to use this for the startup probe. -* `/livez`: Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to using this for the liveness probe. -* `/readyz`: Returns a 200 status code if the application is ready to accept traffic. We recommend using this for the readiness probe. +* `/healthz` (exposed on `main`): Returns a 200 status code if the application is running. We recommend to use this for the startup probe. +* `/livez` (exposed on `main`): Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to using this for the liveness probe. +* `/readyz` (exposed on `self`): Returns a 200 status code if the application is ready to accept traffic. We recommend using this for the readiness probe. Note that it is discouraged to use the telemetry metrics endpoint for any probe when proxying the exposition data. diff --git a/README.md.tpl b/README.md.tpl index 67facfae63..2c57c9990e 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -347,11 +347,11 @@ After running the above, if you see `Clusterrolebinding "cluster-admin-binding" #### Healthcheck Endpoints -The following healthcheck endpoints are available, some of which are used to determine the result of the aforementioned probes: +The following healthcheck endpoints are available (`self` refers to the telemetry port, while `main` refers to the exposition port): -* `/healthz`: Returns a 200 status code if the application is running. We recommend to use this for the startup probe. -* `/livez`: Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to using this for the liveness probe. -* `/readyz`: Returns a 200 status code if the application is ready to accept traffic. We recommend using this for the readiness probe. +* `/healthz` (exposed on `main`): Returns a 200 status code if the application is running. We recommend to use this for the startup probe. +* `/livez` (exposed on `main`): Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to using this for the liveness probe. +* `/readyz` (exposed on `self`): Returns a 200 status code if the application is ready to accept traffic. We recommend using this for the readiness probe. Note that it is discouraged to use the telemetry metrics endpoint for any probe when proxying the exposition data. diff --git a/examples/autosharding/statefulset.yaml b/examples/autosharding/statefulset.yaml index 059832e8f8..a000c2dd93 100644 --- a/examples/autosharding/statefulset.yaml +++ b/examples/autosharding/statefulset.yaml @@ -50,7 +50,7 @@ spec: readinessProbe: httpGet: path: /readyz - port: http-metrics + port: telemetry initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/examples/daemonsetsharding/daemonset.yaml b/examples/daemonsetsharding/daemonset.yaml index f5f8c0908c..6f5d59a6b1 100644 --- a/examples/daemonsetsharding/daemonset.yaml +++ b/examples/daemonsetsharding/daemonset.yaml @@ -45,7 +45,7 @@ spec: readinessProbe: httpGet: path: /readyz - port: http-metrics + port: telemetry initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index dc484a61a1..268f8fb450 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -40,7 +40,7 @@ spec: readinessProbe: httpGet: path: /readyz - port: http-metrics + port: telemetry initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/examples/daemonsetsharding/deployment.yaml b/examples/daemonsetsharding/deployment.yaml index f9ad51f31a..d54a215b1c 100644 --- a/examples/daemonsetsharding/deployment.yaml +++ b/examples/daemonsetsharding/deployment.yaml @@ -39,7 +39,7 @@ spec: readinessProbe: httpGet: path: /readyz - port: http-metrics + port: telemetry initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/examples/standard/deployment.yaml b/examples/standard/deployment.yaml index b34a433774..9130ae7497 100644 --- a/examples/standard/deployment.yaml +++ b/examples/standard/deployment.yaml @@ -37,7 +37,7 @@ spec: readinessProbe: httpGet: path: /readyz - port: http-metrics + port: telemetry initialDelaySeconds: 5 timeoutSeconds: 5 securityContext: diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index 6a96112632..1b2a157dca 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -196,7 +196,7 @@ path: '/livez', } }, readinessProbe: { timeoutSeconds: 5, initialDelaySeconds: 5, httpGet: { - port: "http-metrics", + port: "telemetry", path: '/readyz', } }, }; diff --git a/pkg/app/server.go b/pkg/app/server.go index eee48009f8..a9f1e7c2e6 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -42,6 +42,7 @@ import ( versionCollector "github.com/prometheus/client_golang/prometheus/collectors/version" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promhttp" + "github.com/prometheus/client_golang/prometheus/testutil" "github.com/prometheus/common/version" "github.com/prometheus/exporter-toolkit/web" @@ -377,6 +378,18 @@ func buildTelemetryServer(registry prometheus.Gatherer) *http.ServeMux { // Add metricsPath mux.Handle(metricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{ErrorLog: promLogger{}})) + // Add readyzPath + mux.Handle(readyzPath, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + count, err := testutil.GatherAndCount(registry) + if err != nil || count == 0 { + w.WriteHeader(http.StatusServiceUnavailable) + w.Write([]byte(http.StatusText(http.StatusServiceUnavailable))) + return + } + w.WriteHeader(http.StatusOK) + w.Write([]byte(http.StatusText(http.StatusOK))) + })) + // Add index landingConfig := web.LandingConfig{ Name: "kube-state-metrics", @@ -426,9 +439,6 @@ func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prome // Add livezPath mux.Handle(livezPath, handleClusterDelegationForProber(client, livezPath)) - // Add readyzPath - mux.Handle(readyzPath, handleClusterDelegationForProber(client, readyzPath)) - // Add healthzPath mux.Handle(healthzPath, handleClusterDelegationForProber(client, healthzPath)) From b954ff66f6603c01459033df2bdd7843aa738a87 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 09:48:21 +0000 Subject: [PATCH 044/154] build(deps): Bump actions/setup-go from 5.0.1 to 5.0.2 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.1 to 5.0.2. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/cdcb36043654635271a94b9a6d1392de5bb323a7...0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 16 ++++++++-------- .github/workflows/govulncheck.yml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 729fbe12df..f305704827 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} id: go @@ -54,7 +54,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} id: go @@ -75,7 +75,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} id: go @@ -96,7 +96,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} id: go @@ -117,7 +117,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} id: go @@ -153,7 +153,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} id: go @@ -174,7 +174,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} id: go @@ -195,7 +195,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Go 1.x - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} id: go diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index ea10234a1f..5ed80784e4 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 name: Checkout code - name: Set up Go 1.x - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} - name: Install govulncheck binary From dbb0276a420b0ec9f172c66bbe5905e86e2764c6 Mon Sep 17 00:00:00 2001 From: Pranshu Srivastava Date: Mon, 8 Jul 2024 13:57:38 +0530 Subject: [PATCH 045/154] fixup! fixup! fix: add `readyz` endpoint --- README.md | 2 +- README.md.tpl | 2 +- pkg/app/server.go | 8 +++++--- pkg/util/utils.go | 20 +++++++++++++++++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 58dbf31b5a..5b4b2e214f 100644 --- a/README.md +++ b/README.md @@ -350,7 +350,7 @@ The following healthcheck endpoints are available (`self` refers to the telemetr * `/healthz` (exposed on `main`): Returns a 200 status code if the application is running. We recommend to use this for the startup probe. * `/livez` (exposed on `main`): Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to using this for the liveness probe. -* `/readyz` (exposed on `self`): Returns a 200 status code if the application is ready to accept traffic. We recommend using this for the readiness probe. +* `/readyz` (exposed on `self`): Returns a 200 status code if the application is ready to accept requests and expose metrics. We recommend using this for the readiness probe. Note that it is discouraged to use the telemetry metrics endpoint for any probe when proxying the exposition data. diff --git a/README.md.tpl b/README.md.tpl index 2c57c9990e..5548b022f5 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -351,7 +351,7 @@ The following healthcheck endpoints are available (`self` refers to the telemetr * `/healthz` (exposed on `main`): Returns a 200 status code if the application is running. We recommend to use this for the startup probe. * `/livez` (exposed on `main`): Returns a 200 status code if the application is not affected by an outage of the Kubernetes API Server. We recommend to using this for the liveness probe. -* `/readyz` (exposed on `self`): Returns a 200 status code if the application is ready to accept traffic. We recommend using this for the readiness probe. +* `/readyz` (exposed on `self`): Returns a 200 status code if the application is ready to accept requests and expose metrics. We recommend using this for the readiness probe. Note that it is discouraged to use the telemetry metrics endpoint for any probe when proxying the exposition data. diff --git a/pkg/app/server.go b/pkg/app/server.go index a9f1e7c2e6..253d712fc7 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -42,7 +42,6 @@ import ( versionCollector "github.com/prometheus/client_golang/prometheus/collectors/version" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promhttp" - "github.com/prometheus/client_golang/prometheus/testutil" "github.com/prometheus/common/version" "github.com/prometheus/exporter-toolkit/web" @@ -380,7 +379,7 @@ func buildTelemetryServer(registry prometheus.Gatherer) *http.ServeMux { // Add readyzPath mux.Handle(readyzPath, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - count, err := testutil.GatherAndCount(registry) + count, err := util.GatherAndCount(registry) if err != nil || count == 0 { w.WriteHeader(http.StatusServiceUnavailable) w.Write([]byte(http.StatusText(http.StatusServiceUnavailable))) @@ -440,7 +439,10 @@ func buildMetricsServer(m *metricshandler.MetricsHandler, durationObserver prome mux.Handle(livezPath, handleClusterDelegationForProber(client, livezPath)) // Add healthzPath - mux.Handle(healthzPath, handleClusterDelegationForProber(client, healthzPath)) + mux.HandleFunc(healthzPath, func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + w.Write([]byte(http.StatusText(http.StatusOK))) + }) // Add index landingConfig := web.LandingConfig{ diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 63e5aba650..14b108f37e 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -21,7 +21,6 @@ import ( "runtime" "strings" - "github.com/prometheus/common/version" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/discovery" @@ -32,6 +31,9 @@ import ( "k8s.io/klog/v2" testUnstructuredMock "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/common/version" + "k8s.io/kube-state-metrics/v2/pkg/customresource" ) @@ -154,3 +156,19 @@ func GVRFromType(resourceName string, expectedType interface{}) *schema.GroupVer Resource: r, } } + +// GatherAndCount gathers all metrics from the provided Gatherer and counts +// them. It returns the number of metric children in all gathered metric +// families together. +func GatherAndCount(g prometheus.Gatherer) (int, error) { + got, err := g.Gather() + if err != nil { + return 0, fmt.Errorf("gathering metrics failed: %w", err) + } + + result := 0 + for _, mf := range got { + result += len(mf.GetMetric()) + } + return result, nil +} From eea0524d54652573d28cd3978beaa6c7729bc213 Mon Sep 17 00:00:00 2001 From: SuperQ Date: Fri, 12 Jul 2024 16:24:17 +0200 Subject: [PATCH 046/154] Add automatic detection of memory limits Add automatic detection of container and system memory limits to control the Go `GOMEMLIMIT` garbage collector feature. This helps reduced OOMs by triggering GC when the process approaches system limits. Signed-off-by: SuperQ --- docs/developer/cli-arguments.md | 2 ++ go.mod | 8 ++++++++ go.sum | 19 +++++++++++++++++++ pkg/app/server.go | 15 +++++++++++++++ pkg/options/options.go | 9 +++++++++ 5 files changed, 53 insertions(+) diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index 6648c72278..7f4996a645 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -41,6 +41,8 @@ Flags: --add_dir_header If true, adds the file directory to the header of the log messages --alsologtostderr log to standard error as well as files (no effect when -logtostderr=true) --apiserver string The URL of the apiserver to use as a master + --auto-gomemlimit Automatically set GOMEMLIMIT to match container or system memory limit. (experimental) + --auto-gomemlimit-ratio float The ratio of reserved GOMEMLIMIT memory to the detected maximum container or system memory. (experimental) (default 0.9) --config string Path to the kube-state-metrics options config file --custom-resource-state-config string Inline Custom Resource State Metrics config YAML (experimental) --custom-resource-state-config-file string Path to a Custom Resource State Metrics config file (experimental) diff --git a/go.mod b/go.mod index a3a99a8791..1ba17f2ad2 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.22.0 toolchain go1.22.2 require ( + github.com/KimMachineGun/automemlimit v0.6.1 github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 github.com/fsnotify/fsnotify v1.7.0 github.com/gobuffalo/flect v1.0.2 @@ -32,8 +33,11 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cilium/ebpf v0.9.1 // indirect + github.com/containerd/cgroups/v3 v3.0.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/docker/go-units v0.4.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/go-kit/log v0.2.1 // indirect @@ -42,6 +46,7 @@ require ( github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect + github.com/godbus/dbus/v5 v5.0.4 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect @@ -60,12 +65,15 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect + github.com/opencontainers/runtime-spec v1.0.2 // indirect + github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sirupsen/logrus v1.8.1 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect diff --git a/go.sum b/go.sum index 9b26002967..29e03ba364 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,15 @@ +github.com/KimMachineGun/automemlimit v0.6.1 h1:ILa9j1onAAMadBsyyUJv5cack8Y1WT26yLj/V+ulKp8= +github.com/KimMachineGun/automemlimit v0.6.1/go.mod h1:T7xYht7B8r6AG/AqFcUdc7fzd2bIdBKmepfP2S1svPY= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cilium/ebpf v0.9.1 h1:64sn2K3UKw8NbP/blsixRpF3nXuyhz/VjRlRzvlBRu4= +github.com/cilium/ebpf v0.9.1/go.mod h1:+OhNOIXx/Fnu1IE8bJz2dzOA+VSfyTfdNUVdlQnxUFY= +github.com/containerd/cgroups/v3 v3.0.1 h1:4hfGvu8rfGIwVIDd+nLzn/B9ZXx4BcCjzt5ToenJRaE= +github.com/containerd/cgroups/v3 v3.0.1/go.mod h1:/vtwk1VXrtoa5AaZLkypuOJgA/6DyPMZHJPGQNtlHnw= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -14,6 +20,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 h1:0wH6nO9QEa02Qx8sIQGw6ieKdz+BXjpccSOo9vXNl4U= github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0/go.mod h1:4hKCXuwrJoYvHZxJ86+bRVTOMyJ0Ej+RqfSm8mHi6KA= +github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= @@ -38,6 +46,7 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= +github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -97,6 +106,10 @@ github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= github.com/onsi/gomega v1.31.0 h1:54UJxxj6cPInHS3a35wm6BK/F9nHYueZ1NVujHDrnXE= github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= +github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0= +github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -123,6 +136,8 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -139,6 +154,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -150,6 +166,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -176,6 +194,7 @@ golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/pkg/app/server.go b/pkg/app/server.go index 6a7db543e5..6cc930a765 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -36,6 +36,7 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" + "github.com/KimMachineGun/automemlimit/memlimit" "github.com/oklog/run" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/collectors" @@ -159,6 +160,20 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { } } + if opts.AutoGoMemlimit { + if _, err := memlimit.SetGoMemLimitWithOpts( + memlimit.WithRatio(opts.AutoGoMemlimitRatio), + memlimit.WithProvider( + memlimit.ApplyFallback( + memlimit.FromCgroup, + memlimit.FromSystem, + ), + ), + ); err != nil { + return fmt.Errorf("failed to set GOMEMLIMIT automatically: %w", err) + } + } + kubeConfig, err := clientcmd.BuildConfigFromFlags(opts.Apiserver, opts.Kubeconfig) if err != nil { return fmt.Errorf("failed to build config from flags: %v", err) diff --git a/pkg/options/options.go b/pkg/options/options.go index f537e077c7..74debacab1 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -42,6 +42,8 @@ var ( type Options struct { AnnotationsAllowList LabelsAllowList `yaml:"annotations_allow_list"` Apiserver string `yaml:"apiserver"` + AutoGoMemlimit bool `yaml:"auto-gomemlimit"` + AutoGoMemlimitRatio float64 `yaml:"auto-gomemlimit-ratio"` CustomResourceConfig string `yaml:"custom_resource_config"` CustomResourceConfigFile string `yaml:"custom_resource_config_file"` CustomResourcesOnly bool `yaml:"custom_resources_only"` @@ -143,6 +145,8 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().IntVar(&o.TelemetryPort, "telemetry-port", 8081, `Port to expose kube-state-metrics self metrics on.`) o.cmd.Flags().IntVar(&o.TotalShards, "total-shards", 1, "The total number of shards. Sharding is disabled when total shards is set to 1.") o.cmd.Flags().StringVar(&o.Apiserver, "apiserver", "", `The URL of the apiserver to use as a master`) + o.cmd.Flags().BoolVar(&o.AutoGoMemlimit, "auto-gomemlimit", false, "Automatically set GOMEMLIMIT to match container or system memory limit. (experimental)") + o.cmd.Flags().Float64Var(&o.AutoGoMemlimitRatio, "auto-gomemlimit-ratio", float64(0.9), "The ratio of reserved GOMEMLIMIT memory to the detected maximum container or system memory. (experimental)") o.cmd.Flags().StringVar(&o.CustomResourceConfig, "custom-resource-state-config", "", "Inline Custom Resource State Metrics config YAML (experimental)") o.cmd.Flags().StringVar(&o.CustomResourceConfigFile, "custom-resource-state-config-file", "", "Path to a Custom Resource State Metrics config file (experimental)") o.cmd.Flags().StringVar(&o.Host, "host", "::", `Host to expose metrics on.`) @@ -190,5 +194,10 @@ func (o *Options) Validate() error { return fmt.Errorf("resource %s can't be sharded by field selector spec.nodeName", x) } } + + if o.AutoGoMemlimitRatio <= 0.0 || o.AutoGoMemlimitRatio > 1.0 { + return fmt.Errorf("value for --auto-gomemlimit-ratio=%f must be greater than 0 and less than or equal to 1", o.AutoGoMemlimitRatio) + } + return nil } From 2e4b3e4965981cc8d6c5f52b2f925e3e95b7d51b Mon Sep 17 00:00:00 2001 From: sanadhis Date: Wed, 10 Jul 2024 16:35:14 +0200 Subject: [PATCH 047/154] chore: add kustomization to standard example --- examples/standard/kustomization.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 examples/standard/kustomization.yaml diff --git a/examples/standard/kustomization.yaml b/examples/standard/kustomization.yaml new file mode 100644 index 0000000000..2090c7fd94 --- /dev/null +++ b/examples/standard/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: kube-system + +resources: +- cluster-role.yaml +- cluster-role-binding.yaml +- service-account.yaml +- deployment.yaml +- service.yaml From b4f4dff5c57624b7a511d41fbdb516a30c45b30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 14 Jun 2024 11:53:01 +0200 Subject: [PATCH 048/154] Bump dependencies --- Makefile | 4 ++-- go.mod | 14 +++++++------- go.sum | 24 ++++++++++++------------ tools/go.mod | 23 +++++++++++------------ tools/go.sum | 46 ++++++++++++++++++++++------------------------ 5 files changed, 54 insertions(+), 57 deletions(-) diff --git a/Makefile b/Makefile index f49c08d9ca..467b73e6b0 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ GIT_COMMIT ?= $(shell git rev-parse --short HEAD) OS ?= $(shell uname -s | tr A-Z a-z) ALL_ARCH = amd64 arm arm64 ppc64le s390x PKG = github.com/prometheus/common -PROMETHEUS_VERSION = 2.51.1 -GO_VERSION = 1.22.2 +PROMETHEUS_VERSION = 2.53.1 +GO_VERSION = 1.22.5 IMAGE = $(REGISTRY)/kube-state-metrics MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) USER ?= $(shell id -u -n) diff --git a/go.mod b/go.mod index 1ba17f2ad2..f51bc6d30a 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module k8s.io/kube-state-metrics/v2 go 1.22.0 -toolchain go1.22.2 +toolchain go1.22.5 require ( github.com/KimMachineGun/automemlimit v0.6.1 @@ -20,13 +20,13 @@ require ( github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.30.2 - k8s.io/apimachinery v0.30.2 - k8s.io/client-go v0.30.2 - k8s.io/component-base v0.30.2 + k8s.io/api v0.30.3 + k8s.io/apimachinery v0.30.3 + k8s.io/client-go v0.30.3 + k8s.io/component-base v0.30.3 k8s.io/klog/v2 v2.130.1 - k8s.io/sample-controller v0.30.2 - k8s.io/utils v0.0.0-20240310230437-4693a0247e57 + k8s.io/sample-controller v0.30.3 + k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 ) require ( diff --git a/go.sum b/go.sum index 29e03ba364..d22a722d59 100644 --- a/go.sum +++ b/go.sum @@ -231,22 +231,22 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI= -k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI= -k8s.io/apimachinery v0.30.2 h1:fEMcnBj6qkzzPGSVsAZtQThU62SmQ4ZymlXRC5yFSCg= -k8s.io/apimachinery v0.30.2/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50= -k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs= -k8s.io/component-base v0.30.2 h1:pqGBczYoW1sno8q9ObExUqrYSKhtE5rW3y6gX88GZII= -k8s.io/component-base v0.30.2/go.mod h1:yQLkQDrkK8J6NtP+MGJOws+/PPeEXNpwFixsUI7h/OE= +k8s.io/api v0.30.3 h1:ImHwK9DCsPA9uoU3rVh4QHAHHK5dTSv1nxJUapx8hoQ= +k8s.io/api v0.30.3/go.mod h1:GPc8jlzoe5JG3pb0KJCSLX5oAFIW3/qNJITlDj8BH04= +k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc= +k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/client-go v0.30.3 h1:bHrJu3xQZNXIi8/MoxYtZBBWQQXwy16zqJwloXXfD3k= +k8s.io/client-go v0.30.3/go.mod h1:8d4pf8vYu665/kUbsxWAQ/JDBNWqfFeZnvFiVdmx89U= +k8s.io/component-base v0.30.3 h1:Ci0UqKWf4oiwy8hr1+E3dsnliKnkMLZMVbWzeorlk7s= +k8s.io/component-base v0.30.3/go.mod h1:C1SshT3rGPCuNtBs14RmVD2xW0EhRSeLvBh7AGk1quA= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= -k8s.io/sample-controller v0.30.2 h1:J8Xvli+YHS6C7sWFzn00N2CAtkvLOguXj+Iq4S3oMwA= -k8s.io/sample-controller v0.30.2/go.mod h1:Btgcc0ZQfurowzwy4e7v3wx4hE1AADwzhZ+apsJ4J8Y= -k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY= -k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/sample-controller v0.30.3 h1:oZTxERF8U3gANT2H5VxpkW32asgmW0IYGyUv9Opspvs= +k8s.io/sample-controller v0.30.3/go.mod h1:yhy/cWCzevQLa2+7Gvj0J9+xzmNExypunffSNANBy7o= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= +k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/tools/go.mod b/tools/go.mod index abab5867a0..ce3ed7dd37 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -8,13 +8,12 @@ require ( github.com/google/go-jsonnet v0.20.0 github.com/hairyhenderson/gomplate/v3 v3.11.8 github.com/jsonnet-bundler/jsonnet-bundler v0.5.1 - golang.org/x/perf v0.0.0-20231127181059-b53752263861 + golang.org/x/perf v0.0.0-20240604174448-3b48cf0e0164 ) require ( cloud.google.com/go v0.110.7 // indirect - cloud.google.com/go/compute v1.23.0 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/compute/metadata v0.3.0 // indirect cloud.google.com/go/iam v1.1.1 // indirect cloud.google.com/go/storage v1.30.1 // indirect dario.cat/mergo v1.0.0 // indirect @@ -125,16 +124,16 @@ require ( go4.org/intern v0.0.0-20230205224052-192e9f60865c // indirect go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect gocloud.dev v0.25.1-0.20220408200107-09b10f7359f7 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/oauth2 v0.15.0 // indirect - golang.org/x/sync v0.5.0 // indirect - golang.org/x/sys v0.20.0 // indirect - golang.org/x/term v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect + golang.org/x/crypto v0.24.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/term v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect - golang.org/x/tools v0.13.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/tools/go.sum b/tools/go.sum index 7d8da6ff96..bb82af7f3b 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -43,10 +43,8 @@ cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTB cloud.google.com/go/compute v1.2.0/go.mod h1:xlogom/6gr8RJGBe7nT2eGsQYAFUbbv8dbC29qE3Xmw= cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= -cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= @@ -925,8 +923,8 @@ golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -965,8 +963,8 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1026,8 +1024,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1048,10 +1046,10 @@ golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= -golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= -golang.org/x/perf v0.0.0-20231127181059-b53752263861 h1:oWUgm6RG0ZUKQeX7wxjnX+TFCrXDSheBtpiy5vpUdZg= -golang.org/x/perf v0.0.0-20231127181059-b53752263861/go.mod h1:sKqUfjZtdM78wIFCYFnmu2FhhanvRUbp67Zgmj3TZPM= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/perf v0.0.0-20240604174448-3b48cf0e0164 h1:EUu0oOwLbhVs3v7r1ulLp3a3czQ3XkvKcBGOMfft+nw= +golang.org/x/perf v0.0.0-20240604174448-3b48cf0e0164/go.mod h1:yzNzwBKxdK25sFy9NWFu/abeZOeugePuXQfvVIDA8os= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1065,8 +1063,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1162,8 +1160,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1171,8 +1169,8 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= +golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1186,8 +1184,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1262,8 +1260,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From b8c11661534ceb060ae3885bd5f261cfec140fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 14 Jun 2024 11:53:29 +0200 Subject: [PATCH 049/154] *: Cut 2.13.0 --- CHANGELOG.md | 15 +++++++++++++++ README.md | 6 +++--- data.yaml | 6 +++--- examples/autosharding/cluster-role-binding.yaml | 2 +- examples/autosharding/cluster-role.yaml | 2 +- examples/autosharding/role-binding.yaml | 2 +- examples/autosharding/role.yaml | 2 +- examples/autosharding/service-account.yaml | 2 +- examples/autosharding/service.yaml | 2 +- examples/autosharding/statefulset.yaml | 6 +++--- .../daemonsetsharding/cluster-role-binding.yaml | 2 +- examples/daemonsetsharding/cluster-role.yaml | 2 +- examples/daemonsetsharding/daemonset-service.yaml | 2 +- examples/daemonsetsharding/daemonset.yaml | 6 +++--- .../deployment-no-node-pods.yaml | 6 +++--- .../daemonsetsharding/deployment-service.yaml | 2 +- examples/daemonsetsharding/deployment.yaml | 6 +++--- examples/daemonsetsharding/service-account.yaml | 2 +- examples/standard/cluster-role-binding.yaml | 2 +- examples/standard/cluster-role.yaml | 2 +- examples/standard/deployment.yaml | 6 +++--- examples/standard/service-account.yaml | 2 +- examples/standard/service.yaml | 2 +- 23 files changed, 51 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb8e66c011..97397f9ce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +## v2.13.0 / 2024-07-18 + +### Note + +* This release builds with Golang `v1.22.5`. +* This release builds with `k8s.io/client-go`: `v0.30.3`. +* This release adds read and write timeouts for requests. The defaults might have an impact on scrapes that take a long time. + +* [BUGFIX] Pod autosharding: transition from labelselector to fieldselector by @pkoutsovasilis in +* [ENHANCEMENT] Add automatic detection of memory limits by @SuperQ in +* [FEATURE] Add `readyz` endpoint by @rexagod in +* [FEATURE] Add `livez` endpoint by @rexagod in +* [FEATURE] Add kube_persistentvolume_volume_mode metric by @ricardoapl in +* [FEATURE] Add read and write timeouts by @Pokom in + ## v2.12.0 / 2024-04-02 ### Note diff --git a/README.md b/README.md index 5b4b2e214f..d6a486c2c4 100644 --- a/README.md +++ b/README.md @@ -79,11 +79,11 @@ Generally, it is recommended to use the latest release of kube-state-metrics. If | kube-state-metrics | Kubernetes client-go Version | |--------------------|:----------------------------:| -| **v2.8.2** | v1.26 | | **v2.9.2** | v1.26 | | **v2.10.1** | v1.27 | | **v2.11.0** | v1.28 | | **v2.12.0** | v1.29 | +| **v2.13.0** | v1.30 | | **main** | v1.30 | #### Resource group version compatibility @@ -96,8 +96,8 @@ release. The latest container image can be found at: -* `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0` (arch: `amd64`, `arm`, `arm64`, `ppc64le` and `s390x`) -* View all multi-architecture images at [here](https://explore.ggcr.dev/?image=registry.k8s.io%2Fkube-state-metrics%2Fkube-state-metrics:v2.12.0) +* `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0` (arch: `amd64`, `arm`, `arm64`, `ppc64le` and `s390x`) +* View all multi-architecture images at [here](https://explore.ggcr.dev/?image=registry.k8s.io%2Fkube-state-metrics%2Fkube-state-metrics:v2.13.0) ### Metrics Documentation diff --git a/data.yaml b/data.yaml index 22ed73d56b..a5876cd726 100644 --- a/data.yaml +++ b/data.yaml @@ -1,12 +1,10 @@ # The purpose of this config is to keep all versions in a single file and make them machine accessible # Marks the latest release -version: "2.12.0" +version: "2.13.0" # List at max 5 releases here + the main branch compat: - - version: "v2.8.2" - kubernetes: "1.26" - version: "v2.9.2" kubernetes: "1.26" - version: "v2.10.1" @@ -15,5 +13,7 @@ compat: kubernetes: "1.28" - version: "v2.12.0" kubernetes: "1.29" + - version: "v2.13.0" + kubernetes: "1.30" - version: "main" kubernetes: "1.30" diff --git a/examples/autosharding/cluster-role-binding.yaml b/examples/autosharding/cluster-role-binding.yaml index 917460705c..11cdc294a8 100644 --- a/examples/autosharding/cluster-role-binding.yaml +++ b/examples/autosharding/cluster-role-binding.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics roleRef: apiGroup: rbac.authorization.k8s.io diff --git a/examples/autosharding/cluster-role.yaml b/examples/autosharding/cluster-role.yaml index 39b6cdc73a..d330803f9b 100644 --- a/examples/autosharding/cluster-role.yaml +++ b/examples/autosharding/cluster-role.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics rules: - apiGroups: diff --git a/examples/autosharding/role-binding.yaml b/examples/autosharding/role-binding.yaml index 2bf840aa54..a8bc73d9c1 100644 --- a/examples/autosharding/role-binding.yaml +++ b/examples/autosharding/role-binding.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system roleRef: diff --git a/examples/autosharding/role.yaml b/examples/autosharding/role.yaml index e3c0201e40..464e44658c 100644 --- a/examples/autosharding/role.yaml +++ b/examples/autosharding/role.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system rules: diff --git a/examples/autosharding/service-account.yaml b/examples/autosharding/service-account.yaml index 3f37231919..8107dcf62c 100644 --- a/examples/autosharding/service-account.yaml +++ b/examples/autosharding/service-account.yaml @@ -5,6 +5,6 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system diff --git a/examples/autosharding/service.yaml b/examples/autosharding/service.yaml index 279e867735..f32d1001bb 100644 --- a/examples/autosharding/service.yaml +++ b/examples/autosharding/service.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system spec: diff --git a/examples/autosharding/statefulset.yaml b/examples/autosharding/statefulset.yaml index a000c2dd93..a0ccaad8d2 100644 --- a/examples/autosharding/statefulset.yaml +++ b/examples/autosharding/statefulset.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system spec: @@ -18,7 +18,7 @@ spec: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 spec: automountServiceAccountToken: true containers: @@ -34,7 +34,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 + image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 livenessProbe: httpGet: path: /livez diff --git a/examples/daemonsetsharding/cluster-role-binding.yaml b/examples/daemonsetsharding/cluster-role-binding.yaml index 917460705c..11cdc294a8 100644 --- a/examples/daemonsetsharding/cluster-role-binding.yaml +++ b/examples/daemonsetsharding/cluster-role-binding.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics roleRef: apiGroup: rbac.authorization.k8s.io diff --git a/examples/daemonsetsharding/cluster-role.yaml b/examples/daemonsetsharding/cluster-role.yaml index 39b6cdc73a..d330803f9b 100644 --- a/examples/daemonsetsharding/cluster-role.yaml +++ b/examples/daemonsetsharding/cluster-role.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics rules: - apiGroups: diff --git a/examples/daemonsetsharding/daemonset-service.yaml b/examples/daemonsetsharding/daemonset-service.yaml index 35560e4354..82bbc568bb 100644 --- a/examples/daemonsetsharding/daemonset-service.yaml +++ b/examples/daemonsetsharding/daemonset-service.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics-shard - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics-shard namespace: kube-system spec: diff --git a/examples/daemonsetsharding/daemonset.yaml b/examples/daemonsetsharding/daemonset.yaml index 6f5d59a6b1..f0d78d6fd7 100644 --- a/examples/daemonsetsharding/daemonset.yaml +++ b/examples/daemonsetsharding/daemonset.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics-shard - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics-shard namespace: kube-system spec: @@ -16,7 +16,7 @@ spec: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics-shard - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 spec: automountServiceAccountToken: true containers: @@ -29,7 +29,7 @@ spec: fieldRef: apiVersion: v1 fieldPath: spec.nodeName - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 + image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 livenessProbe: httpGet: path: /livez diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index 268f8fb450..6bea075af7 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics-pods - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics-pods namespace: kube-system spec: @@ -17,14 +17,14 @@ spec: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 spec: automountServiceAccountToken: true containers: - args: - --resources=pods - --node="" - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 + image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 livenessProbe: httpGet: path: /livez diff --git a/examples/daemonsetsharding/deployment-service.yaml b/examples/daemonsetsharding/deployment-service.yaml index 279e867735..f32d1001bb 100644 --- a/examples/daemonsetsharding/deployment-service.yaml +++ b/examples/daemonsetsharding/deployment-service.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system spec: diff --git a/examples/daemonsetsharding/deployment.yaml b/examples/daemonsetsharding/deployment.yaml index d54a215b1c..fcc95bceb5 100644 --- a/examples/daemonsetsharding/deployment.yaml +++ b/examples/daemonsetsharding/deployment.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system spec: @@ -17,13 +17,13 @@ spec: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 spec: automountServiceAccountToken: true containers: - args: - --resources=certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 + image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 livenessProbe: httpGet: path: /livez diff --git a/examples/daemonsetsharding/service-account.yaml b/examples/daemonsetsharding/service-account.yaml index 3f37231919..8107dcf62c 100644 --- a/examples/daemonsetsharding/service-account.yaml +++ b/examples/daemonsetsharding/service-account.yaml @@ -5,6 +5,6 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system diff --git a/examples/standard/cluster-role-binding.yaml b/examples/standard/cluster-role-binding.yaml index 917460705c..11cdc294a8 100644 --- a/examples/standard/cluster-role-binding.yaml +++ b/examples/standard/cluster-role-binding.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics roleRef: apiGroup: rbac.authorization.k8s.io diff --git a/examples/standard/cluster-role.yaml b/examples/standard/cluster-role.yaml index 39b6cdc73a..d330803f9b 100644 --- a/examples/standard/cluster-role.yaml +++ b/examples/standard/cluster-role.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics rules: - apiGroups: diff --git a/examples/standard/deployment.yaml b/examples/standard/deployment.yaml index 9130ae7497..85539fc1d4 100644 --- a/examples/standard/deployment.yaml +++ b/examples/standard/deployment.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system spec: @@ -17,11 +17,11 @@ spec: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 spec: automountServiceAccountToken: true containers: - - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.12.0 + - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 livenessProbe: httpGet: path: /livez diff --git a/examples/standard/service-account.yaml b/examples/standard/service-account.yaml index 3f37231919..8107dcf62c 100644 --- a/examples/standard/service-account.yaml +++ b/examples/standard/service-account.yaml @@ -5,6 +5,6 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system diff --git a/examples/standard/service.yaml b/examples/standard/service.yaml index 279e867735..f32d1001bb 100644 --- a/examples/standard/service.yaml +++ b/examples/standard/service.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics namespace: kube-system spec: From 8753dfd5b7a5ef0354f6eb6cd9ba0748daf78e28 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Fri, 19 Jul 2024 16:08:44 +0100 Subject: [PATCH 050/154] Fix missing line break escape on sbom workflow Signed-off-by: Ricardo Lopes --- .github/workflows/sbom.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index 73949a0204..ec30c377b6 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -31,7 +31,7 @@ jobs: bom generate \ --dirs=. \ --image=registry.k8s.io/kube-state-metrics/kube-state-metrics:$TAG \ - --namespace=https://github.com/kubernetes/kube-state-metrics/releases/download/$TAG/$OUTPUT + --namespace=https://github.com/kubernetes/kube-state-metrics/releases/download/$TAG/$OUTPUT \ --output=$OUTPUT - name: Upload SBOM to GitHub Release From b45913db5963958c0008cb5f8a608402f3b74c1c Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Fri, 17 May 2024 07:37:19 -0400 Subject: [PATCH 051/154] Fix --nodeName= doesn't select unscheduable pods pods --- README.md | 2 +- README.md.tpl | 2 +- .../deployment-no-node-pods-service.yaml | 20 ++++++++++++ .../deployment-no-node-pods.yaml | 10 +++--- .../kube-state-metrics.libsonnet | 32 ++++++++++++++++++- pkg/options/types.go | 16 ++++++---- 6 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 examples/daemonsetsharding/deployment-no-node-pods-service.yaml diff --git a/README.md b/README.md index d6a486c2c4..5ee7da90ff 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--node=""`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--node=`, as shown in the following example: ``` apiVersion: apps/v1 diff --git a/README.md.tpl b/README.md.tpl index 5548b022f5..59c7d4ed57 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -283,7 +283,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--node=""`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--node=`, as shown in the following example: ``` apiVersion: apps/v1 diff --git a/examples/daemonsetsharding/deployment-no-node-pods-service.yaml b/examples/daemonsetsharding/deployment-no-node-pods-service.yaml new file mode 100644 index 0000000000..5f287b7aa1 --- /dev/null +++ b/examples/daemonsetsharding/deployment-no-node-pods-service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: exporter + app.kubernetes.io/name: kube-state-metrics-no-node-pods + app.kubernetes.io/version: 2.12.0 + name: kube-state-metrics-no-node-pods + namespace: kube-system +spec: + clusterIP: None + ports: + - name: http-metrics + port: 8080 + targetPort: http-metrics + - name: telemetry + port: 8081 + targetPort: telemetry + selector: + app.kubernetes.io/name: kube-state-metrics-no-node-pods diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index 6bea075af7..31a24bbef5 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -3,20 +3,20 @@ kind: Deployment metadata: labels: app.kubernetes.io/component: exporter - app.kubernetes.io/name: kube-state-metrics-pods + app.kubernetes.io/name: kube-state-metrics-no-node-pods app.kubernetes.io/version: 2.13.0 - name: kube-state-metrics-pods + name: kube-state-metrics-no-node-pods namespace: kube-system spec: replicas: 1 selector: matchLabels: - app.kubernetes.io/name: kube-state-metrics + app.kubernetes.io/name: kube-state-metrics-no-node-pods template: metadata: labels: app.kubernetes.io/component: exporter - app.kubernetes.io/name: kube-state-metrics + app.kubernetes.io/name: kube-state-metrics-no-node-pods app.kubernetes.io/version: 2.13.0 spec: automountServiceAccountToken: true @@ -31,7 +31,7 @@ spec: port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 - name: kube-state-metrics + name: kube-state-metrics-no-node-pods ports: - containerPort: 8080 name: http-metrics diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index 1b2a157dca..db61449c7f 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -379,8 +379,9 @@ '--resources=pods', '--node=""', ], + name: shardksmname, }; - local shardksmname = ksm.name + "-pods"; + local shardksmname = ksm.name + "-no-node-pods"; std.mergePatch(ksm.deployment, { metadata: { @@ -388,7 +389,15 @@ labels: {'app.kubernetes.io/name': shardksmname} }, spec: { + selector{ + matchLabels: {app.kubernetes.io/name': shardksmname} + } template: { + metadata: { + labels: { + app.kubernetes.io/name': shardksmname + } + } spec: { containers: [c], }, @@ -397,6 +406,27 @@ }, ), + deploymentNoNodePodsService: + local c = ksm.deployment.spec.template.spec.containers[0] { + args: [ + '--resources=pods', + '--node=""', + ], + }; + local shardksmname = ksm.name + "-no-node-pods"; + std.mergePatch(ksm.service, + { + metadata: { + name: shardksmname, + labels: {'app.kubernetes.io/name': shardksmname} + }, + spec: { + selector: { + 'app.kubernetes.io/name': shardksmname + } + } + } + ), daemonset: // extending the default container from above local c0 = ksm.deployment.spec.template.spec.containers[0] { diff --git a/pkg/options/types.go b/pkg/options/types.go index 9f03ec863b..91d7d778d4 100644 --- a/pkg/options/types.go +++ b/pkg/options/types.go @@ -18,7 +18,6 @@ package options import ( "errors" - "regexp" "sort" "strings" @@ -141,15 +140,18 @@ func (n *NodeType) Type() string { // GetNodeFieldSelector returns a nodename field selector. func (n *NodeType) GetNodeFieldSelector() string { - if nil == n || len(*n) == 0 { + if nil == n { klog.InfoS("Using node type is nil") return EmptyFieldSelector() } - pattern := "[^a-zA-Z0-9_,-]+" - re := regexp.MustCompile(pattern) - result := re.ReplaceAllString(n.String(), "") - klog.InfoS("Using node type", "node", result) - return fields.OneTermEqualSelector("spec.nodeName", result).String() + nodeName := n.String() + // `--node=""` find pods without node name assigned which uses fieldselector spec.nodeName="" + klog.InfoS("Using node name", nodeName) + if nodeName == "" { + klog.InfoS("Using spec.nodeName= to select unscheduable pods without node") + return "spec.nodeName=" + } + return fields.OneTermEqualSelector("spec.nodeName", nodeName).String() } From 8f3c5c432bc2d2800d471d71c703eeb7125d6604 Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Wed, 5 Jun 2024 09:36:09 -0400 Subject: [PATCH 052/154] Add e2e test --- pkg/options/types.go | 2 + tests/e2e.sh | 79 +++++++++++++++++++++++++++++++----- tests/e2e/testdata/pods.yaml | 75 ++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 tests/e2e/testdata/pods.yaml diff --git a/pkg/options/types.go b/pkg/options/types.go index 91d7d778d4..376ef9b526 100644 --- a/pkg/options/types.go +++ b/pkg/options/types.go @@ -130,6 +130,7 @@ func (n NodeType) AsSlice() []string { } func (n NodeType) String() string { + klog.InfoS("n.AsSlice()", n.AsSlice()) return strings.Join(n.AsSlice(), ",") } @@ -151,6 +152,7 @@ func (n *NodeType) GetNodeFieldSelector() string { klog.InfoS("Using spec.nodeName= to select unscheduable pods without node") return "spec.nodeName=" } + klog.InfoS("Using spec.nodeName=", nodeName) return fields.OneTermEqualSelector("spec.nodeName", nodeName).String() } diff --git a/tests/e2e.sh b/tests/e2e.sh index 4cb89f6336..8a8773d4b0 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +set -x set -e set -o pipefail @@ -75,10 +76,14 @@ set +e kubectl proxy & function kube_state_metrics_up() { + serviceName="kube-state-metrics" + if [[ -n "$1" ]]; then + serviceName="$1" + fi is_kube_state_metrics_running="false" # this for loop waits until kube-state-metrics is running by accessing the healthz endpoint for _ in {1..30}; do # timeout for 1 minutes - KUBE_STATE_METRICS_STATUS=$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:http-metrics/proxy/healthz") + KUBE_STATE_METRICS_STATUS=$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/${serviceName}:http-metrics/proxy/healthz") if [[ "${KUBE_STATE_METRICS_STATUS}" == "OK" ]]; then is_kube_state_metrics_running="true" break @@ -94,27 +99,76 @@ function kube_state_metrics_up() { exit 1 fi } +function kube_pod_up() { + is_pod_running="false" + + for _ in {1..90}; do # timeout for 3 minutes + kubectl get pods -A | grep "$1" 1>/dev/null 2>&1 + if [[ $? -ne 1 ]]; then + is_pod_running="true" + break + fi + + echo "waiting for pod $1 to come up" + sleep 2 + done + + if [[ ${is_pod_running} == "false" ]]; then + echo "Pod does not show up within 3 minutes" + exit 1 + fi +} + function test_daemonset() { sed -i "s|${KUBE_STATE_METRICS_CURRENT_IMAGE_NAME}:v.*|${KUBE_STATE_METRICS_IMAGE_NAME}:${KUBE_STATE_METRICS_IMAGE_TAG}|g" ./examples/daemonsetsharding/deployment.yaml sed -i "s|${KUBE_STATE_METRICS_CURRENT_IMAGE_NAME}:v.*|${KUBE_STATE_METRICS_IMAGE_NAME}:${KUBE_STATE_METRICS_IMAGE_TAG}|g" ./examples/daemonsetsharding/daemonset.yaml + sed -i "s|${KUBE_STATE_METRICS_CURRENT_IMAGE_NAME}:v.*|${KUBE_STATE_METRICS_IMAGE_NAME}:${KUBE_STATE_METRICS_IMAGE_TAG}|g" ./examples/daemonsetsharding/deployment-no-node-pods.yaml + cat ./examples/daemonsetsharding/deployment-no-node-pods.yaml + sleep 3 kubectl get deployment -n kube-system - kubectl create -f ./examples/daemonsetsharding ls ./examples/daemonsetsharding - kube_state_metrics_up - curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-shard:http-metrics/proxy/metrics" >${KUBE_STATE_METRICS_LOG_DIR}/pod-metrics - curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:http-metrics/proxy/metrics" >${KUBE_STATE_METRICS_LOG_DIR}/nonpod-metrics - m1="$(cat ${KUBE_STATE_METRICS_LOG_DIR}/pod-metrics | grep "# TYPE kube_pod_info" || true)" - m2="$(cat ${KUBE_STATE_METRICS_LOG_DIR}/nonpod-metrics | grep "# TYPE kube_pod_info" || true)" - if [[ -z "${m1}" ]]; then - echo "can't found metric kube_pod_info from pod metrics service" + kubectl create -f ./examples/daemonsetsharding + kube_state_metrics_up kube-state-metrics-no-node-pods + kube_state_metrics_up kube-state-metrics + kube_state_metrics_up kube-state-metrics-shard + kubectl apply -f ./tests/e2e/testdata/pods.yaml + kube_pod_up runningpod1 + kube_pod_up pendingpod2 + + kubectl get deployment -n default + # curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-shard:http-metrics/proxy/metrics" >${KUBE_STATE_METRICS_LOG_DIR}/daemonset-scraped-metrics + # curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:http-metrics/proxy/metrics" >${KUBE_STATE_METRICS_LOG_DIR}/deployment-scraped-metrics + # curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-no-node-pods:http-metrics/proxy/metrics" >${KUBE_STATE_METRICS_LOG_DIR}/deployment-scraped-no-node-metrics + + # cat ${KUBE_STATE_METRICS_LOG_DIR}/daemonset-scraped-metrics ${KUBE_STATE_METRICS_LOG_DIR}/deployment-scraped-metrics ${KUBE_STATE_METRICS_LOG_DIR}/deployment-scraped-no-node-metrics >> ${KUBE_STATE_METRICS_LOG_DIR}/all-metrics + # cat ${KUBE_STATE_METRICS_LOG_DIR}/all-metrics | grep "kube_pod_info" + runningpod1="$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-shard:http-metrics/proxy/metrics" | grep "runningpod1" | grep -c "kube_pod_info" )" + node1="$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:http-metrics/proxy/metrics" | grep -c "# TYPE kube_node_info" )" + expected_num_pod=1 + if [ "${runningpod1}" != "${expected_num_pod}" ]; then + echo "metric kube_pod_info for runningpod1 doesn't show up only once, got ${runningpod1} times" exit 1 fi - if [[ -n "${m2}" ]]; then - echo "shouldn't find metric kube_pod_info from non-pod metrics service" + + if [ "${node1}" != "1" ]; then + echo "metric kube_node_info doesn't show up only once, got ${node1} times" exit 1 fi + kubectl logs deployment/kube-state-metrics-no-node-pods -n kube-system + sleep 3 + curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-no-node-pods:http-metrics/proxy/metrics" + sleep 3 + kubectl get pods -A --field-selector spec.nodeName="" + sleep 3 + pendingpod2="$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-no-node-pods:http-metrics/proxy/metrics" | grep "pendingpod2" | grep -c "kube_pod_info" )" + if [ "${pendingpod2}" != "${expected_num_pod}" ]; then + echo "metric kube_pod_info for pendingpod2 doesn't show up only once, got ${runningpod1} times" + exit 1 + fi + + kubectl delete -f ./tests/e2e/testdata/pods.yaml kubectl delete -f ./examples/daemonsetsharding sleep 20 } @@ -144,6 +198,9 @@ set -e kubectl version # query kube-state-metrics image tag +cat pkg/options/types.go +sleep 3 + REGISTRY="registry.k8s.io/kube-state-metrics" make container docker images -a KUBE_STATE_METRICS_IMAGE_TAG=$(docker images -a|grep "${KUBE_STATE_METRICS_IMAGE_NAME}" |grep -v 'latest'|awk '{print $2}'|sort -u) diff --git a/tests/e2e/testdata/pods.yaml b/tests/e2e/testdata/pods.yaml new file mode 100644 index 0000000000..523e7b3317 --- /dev/null +++ b/tests/e2e/testdata/pods.yaml @@ -0,0 +1,75 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: pendingpod2 + name: pendingpod2 + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: pendingpod2 + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + labels: + app: pendingpod2 + spec: + nodeSelector: + debug-node: "non" + containers: + - command: + - /agnhost + - netexec + - --http-port=8080q + image: registry.k8s.io/e2e-test-images/agnhost:2.39 + imagePullPolicy: IfNotPresent + name: agnhost + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + terminationGracePeriodSeconds: 30 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: runningpod1 + name: runningpod1 + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: runningpod1 + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + labels: + app: runningpod1 + spec: + containers: + - command: + - /agnhost + - netexec + - --http-port=8080 + image: registry.k8s.io/e2e-test-images/agnhost:2.39 + imagePullPolicy: IfNotPresent + name: agnhost + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + terminationGracePeriodSeconds: 30 \ No newline at end of file From b27845d5352737457439bc8b8482af442d87d871 Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Fri, 7 Jun 2024 08:12:13 -0400 Subject: [PATCH 053/154] use --enable-no-node-scrape Co-authored-by: Alex Kennedy --- README.md | 4 +- README.md.tpl | 4 +- docs/developer/cli-arguments.md | 1 + .../deployment-no-node-pods.yaml | 2 +- .../kube-state-metrics.libsonnet | 4 +- pkg/app/server.go | 2 +- pkg/options/options.go | 7 +- pkg/options/types.go | 57 ++---------- pkg/options/types_test.go | 93 +++++++------------ tests/e2e.sh | 17 +--- tests/e2e/testdata/pods.yaml | 2 +- 11 files changed, 60 insertions(+), 133 deletions(-) diff --git a/README.md b/README.md index 5ee7da90ff..adf5433620 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--node=`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--enable-no-node-scrape`, as shown in the following example: ``` apiVersion: apps/v1 @@ -295,7 +295,7 @@ spec: name: kube-state-metrics args: - --resources=pods - - --node="" + - --enable-no-node-scrape ``` Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding). diff --git a/README.md.tpl b/README.md.tpl index 59c7d4ed57..a68c47bf21 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -283,7 +283,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--node=`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--enable-no-node-scrape`, as shown in the following example: ``` apiVersion: apps/v1 @@ -296,7 +296,7 @@ spec: name: kube-state-metrics args: - --resources=pods - - --node="" + - --enable-no-node-scrape ``` Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding). diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index 7f4996a645..35b25e5ffd 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -48,6 +48,7 @@ Flags: --custom-resource-state-config-file string Path to a Custom Resource State Metrics config file (experimental) --custom-resource-state-only Only provide Custom Resource State metrics (experimental) --enable-gzip-encoding Gzip responses when requested by clients via 'Accept-Encoding: gzip' header. + --enable-no-node-scrape This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental. -h, --help Print Help text --host string Host to expose metrics on. (default "::") --kubeconfig string Absolute path to the kubeconfig file diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index 31a24bbef5..50fc840afa 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -23,7 +23,7 @@ spec: containers: - args: - --resources=pods - - --node="" + - --enable-no-node-scrape image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 livenessProbe: httpGet: diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index db61449c7f..7ac9f71fe9 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -377,7 +377,7 @@ local c = ksm.deployment.spec.template.spec.containers[0] { args: [ '--resources=pods', - '--node=""', + '--enable-no-node-scrape', ], name: shardksmname, }; @@ -410,7 +410,7 @@ local c = ksm.deployment.spec.template.spec.containers[0] { args: [ '--resources=pods', - '--node=""', + '--enable-no-node-scrape', ], }; local shardksmname = ksm.name + "-no-node-pods"; diff --git a/pkg/app/server.go b/pkg/app/server.go index 9d25fd0e8b..194c0676bb 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -224,7 +224,7 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { namespaces := opts.Namespaces.GetNamespaces() nsFieldSelector := namespaces.GetExcludeNSFieldSelector(opts.NamespacesDenylist) - nodeFieldSelector := opts.Node.GetNodeFieldSelector() + nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.EnableNoNodeScrape) merged, err := storeBuilder.MergeFieldSelectors([]string{nsFieldSelector, nodeFieldSelector}) if err != nil { return err diff --git a/pkg/options/options.go b/pkg/options/options.go index 74debacab1..5899211b66 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -59,6 +59,7 @@ type Options struct { Namespaces NamespaceList `yaml:"namespaces"` NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"` Node NodeType `yaml:"node"` + EnableNoNodeScrape bool `yaml:"enable_no_node_scrape"` Pod string `yaml:"pod"` Port int `yaml:"port"` Resources ResourceSet `yaml:"resources"` @@ -90,7 +91,6 @@ func NewOptions() *Options { MetricAllowlist: MetricSet{}, MetricDenylist: MetricSet{}, MetricOptInList: MetricSet{}, - Node: NodeType{}, AnnotationsAllowList: LabelsAllowList{}, LabelsAllowList: LabelsAllowList{}, } @@ -138,6 +138,7 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().BoolVar(&o.CustomResourcesOnly, "custom-resource-state-only", false, "Only provide Custom Resource State metrics (experimental)") o.cmd.Flags().BoolVar(&o.EnableGZIPEncoding, "enable-gzip-encoding", false, "Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.") + o.cmd.Flags().BoolVar(&o.EnableNoNodeScrape, "enable-no-node-scrape", false, "This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental.") o.cmd.Flags().BoolVarP(&o.Help, "help", "h", false, "Print Help text") o.cmd.Flags().BoolVarP(&o.UseAPIServerCache, "use-apiserver-cache", "", false, "Sets resourceVersion=0 for ListWatch requests, using cached resources from the apiserver instead of an etcd quorum read.") o.cmd.Flags().Int32Var(&o.Shard, "shard", int32(0), "The instances shard nominal (zero indexed) within the total number of shards. (default 0)") @@ -156,7 +157,7 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().StringVar(&o.TLSConfig, "tls-config", "", "Path to the TLS configuration file") o.cmd.Flags().StringVar(&o.TelemetryHost, "telemetry-host", "::", `Host to expose kube-state-metrics self metrics on.`) o.cmd.Flags().StringVar(&o.Config, "config", "", "Path to the kube-state-metrics options config file") - o.cmd.Flags().Var(&o.Node, "node", "Name of the node that contains the kube-state-metrics pod. Most likely it should be passed via the downward API. This is used for daemonset sharding. Only available for resources (pod metrics) that support spec.nodeName fieldSelector. This is experimental.") + o.cmd.Flags().StringVar((*string)(&o.Node), "node", "", "Name of the node that contains the kube-state-metrics pod. Most likely it should be passed via the downward API. This is used for daemonset sharding. Only available for resources (pod metrics) that support spec.nodeName fieldSelector. This is experimental.") o.cmd.Flags().Var(&o.AnnotationsAllowList, "metric-annotations-allowlist", "Comma-separated list of Kubernetes annotations keys that will be used in the resource' labels metric. By default the annotations metrics are not exposed. To include them, provide a list of resource names in their plural form and Kubernetes annotation keys you would like to allow for them (Example: '=namespaces=[kubernetes.io/team,...],pods=[kubernetes.io/team],...)'. A single '*' can be provided per resource instead to allow any annotations, but that has severe performance implications (Example: '=pods=[*]').") o.cmd.Flags().Var(&o.LabelsAllowList, "metric-labels-allowlist", "Comma-separated list of additional Kubernetes label keys that will be used in the resource' labels metric. By default the labels metrics are not exposed. To include them, provide a list of resource names in their plural form and Kubernetes label keys you would like to allow for them (Example: '=namespaces=[k8s-label-1,k8s-label-n,...],pods=[app],...)'. A single '*' can be provided per resource instead to allow any labels, but that has severe performance implications (Example: '=pods=[*]'). Additionally, an asterisk (*) can be provided as a key, which will resolve to all resources, i.e., assuming '--resources=deployments,pods', '=*=[*]' will resolve to '=deployments=[*],pods=[*]'.") o.cmd.Flags().Var(&o.MetricAllowlist, "metric-allowlist", "Comma-separated list of metrics to be exposed. This list comprises of exact metric names and/or regex patterns. The allowlist and denylist are mutually exclusive.") @@ -186,7 +187,7 @@ func (o *Options) Usage() { // Validate validates arguments func (o *Options) Validate() error { shardableResource := "pods" - if o.Node.String() == "" { + if o.Node == "" { return nil } for _, x := range o.Resources.AsSlice() { diff --git a/pkg/options/types.go b/pkg/options/types.go index 376ef9b526..61579d810b 100644 --- a/pkg/options/types.go +++ b/pkg/options/types.go @@ -105,61 +105,18 @@ func (r *ResourceSet) Type() string { } // NodeType represents a nodeName to query from. -type NodeType map[string]struct{} - -// Set converts a comma-separated string of nodename into a slice and appends it to the NodeList -func (n *NodeType) Set(value string) error { - s := *n - cols := strings.Split(value, ",") - for _, col := range cols { - col = strings.TrimSpace(col) - if len(col) != 0 { - s[col] = struct{}{} - } - } - return nil -} - -// AsSlice returns the LabelsAllowList in the form of plain string slice. -func (n NodeType) AsSlice() []string { - cols := make([]string, 0, len(n)) - for col := range n { - cols = append(cols, col) - } - return cols -} - -func (n NodeType) String() string { - klog.InfoS("n.AsSlice()", n.AsSlice()) - return strings.Join(n.AsSlice(), ",") -} - -// Type returns a descriptive string about the NodeList type. -func (n *NodeType) Type() string { - return "string" -} +type NodeType string // GetNodeFieldSelector returns a nodename field selector. -func (n *NodeType) GetNodeFieldSelector() string { - if nil == n { - klog.InfoS("Using node type is nil") - return EmptyFieldSelector() - } - nodeName := n.String() - // `--node=""` find pods without node name assigned which uses fieldselector spec.nodeName="" - klog.InfoS("Using node name", nodeName) - if nodeName == "" { +func (n *NodeType) GetNodeFieldSelector(noNodeAssigned bool) string { + if noNodeAssigned { klog.InfoS("Using spec.nodeName= to select unscheduable pods without node") return "spec.nodeName=" } - klog.InfoS("Using spec.nodeName=", nodeName) - return fields.OneTermEqualSelector("spec.nodeName", nodeName).String() - -} - -// NodeValue represents a nodeName to query from. -type NodeValue interface { - GetNodeFieldSelector() string + if string(*n) != "" { + return fields.OneTermEqualSelector("spec.nodeName", string(*n)).String() + } + return EmptyFieldSelector() } // EmptyFieldSelector returns an empty field selector. diff --git a/pkg/options/types_test.go b/pkg/options/types_test.go index 4b89f76f4f..96ec0675bc 100644 --- a/pkg/options/types_test.go +++ b/pkg/options/types_test.go @@ -162,37 +162,38 @@ func TestNodeFieldSelector(t *testing.T) { Wanted string }{ { - Desc: "with node name", + Desc: "empty node name", + Node: "", Wanted: "", }, { Desc: "with node name", - Node: nil, - Wanted: "", - }, - { - Desc: "empty node name", - Node: NodeType( - map[string]struct{}{ - "": {}, - }, - ), - Wanted: "spec.nodeName=", - }, - { - Desc: "with node name", - Node: NodeType( - map[string]struct{}{ - "k8s-node-1": {}, - }, - ), + Node: "k8s-node-1", Wanted: "spec.nodeName=k8s-node-1", }, } for _, test := range tests { node := test.Node - actual := node.GetNodeFieldSelector() + actual := node.GetNodeFieldSelector(false) + if !reflect.DeepEqual(actual, test.Wanted) { + t.Errorf("Test error for Desc: %s. Want: %+v. Got: %+v.", test.Desc, test.Wanted, actual) + } + } + tests1 := []struct { + Desc string + Node NodeType + Wanted string + }{ + { + Desc: "empty node name", + Node: "", + Wanted: "spec.nodeName=", + }, + } + for _, test := range tests1 { + node := test.Node + actual := node.GetNodeFieldSelector(true) if !reflect.DeepEqual(actual, test.Wanted) { t.Errorf("Test error for Desc: %s. Want: %+v. Got: %+v.", test.Desc, test.Wanted, actual) } @@ -211,67 +212,43 @@ func TestMergeFieldSelectors(t *testing.T) { Desc: "empty DeniedNamespaces", Namespaces: NamespaceList{"default", "kube-system"}, DeniedNamespaces: NamespaceList{}, - Node: NodeType( - map[string]struct{}{ - "": {}, - }, - ), - Wanted: "spec.nodeName=", + Node: "", + Wanted: "", }, { Desc: "all DeniedNamespaces", Namespaces: DefaultNamespaces, DeniedNamespaces: NamespaceList{"some-system"}, - Node: NodeType( - map[string]struct{}{ - "": {}, - }, - ), - Wanted: "metadata.namespace!=some-system,spec.nodeName=", + Node: "", + Wanted: "metadata.namespace!=some-system", }, { Desc: "general case", Namespaces: DefaultNamespaces, DeniedNamespaces: NamespaceList{"case1-system", "case2-system"}, - Node: NodeType( - map[string]struct{}{ - "": {}, - }, - ), - Wanted: "metadata.namespace!=case1-system,metadata.namespace!=case2-system,spec.nodeName=", + Node: "", + Wanted: "metadata.namespace!=case1-system,metadata.namespace!=case2-system", }, { Desc: "empty DeniedNamespaces", Namespaces: NamespaceList{"default", "kube-system"}, DeniedNamespaces: NamespaceList{}, - Node: NodeType( - map[string]struct{}{ - "k8s-node-1": {}, - }, - ), - Wanted: "spec.nodeName=k8s-node-1", + Node: "k8s-node-1", + Wanted: "spec.nodeName=k8s-node-1", }, { Desc: "all DeniedNamespaces", Namespaces: DefaultNamespaces, DeniedNamespaces: NamespaceList{"some-system"}, - Node: NodeType( - map[string]struct{}{ - "k8s-node-1": {}, - }, - ), - Wanted: "metadata.namespace!=some-system,spec.nodeName=k8s-node-1", + Node: "k8s-node-1", + Wanted: "metadata.namespace!=some-system,spec.nodeName=k8s-node-1", }, { Desc: "general case", Namespaces: DefaultNamespaces, DeniedNamespaces: NamespaceList{"case1-system", "case2-system"}, - Node: NodeType( - map[string]struct{}{ - "k8s-node-1": {}, - }, - ), - Wanted: "metadata.namespace!=case1-system,metadata.namespace!=case2-system,spec.nodeName=k8s-node-1", + Node: "k8s-node-1", + Wanted: "metadata.namespace!=case1-system,metadata.namespace!=case2-system,spec.nodeName=k8s-node-1", }, } @@ -279,7 +256,7 @@ func TestMergeFieldSelectors(t *testing.T) { ns := test.Namespaces deniedNS := test.DeniedNamespaces selector1 := ns.GetExcludeNSFieldSelector(deniedNS) - selector2 := test.Node.GetNodeFieldSelector() + selector2 := test.Node.GetNodeFieldSelector(false) actual, err := MergeFieldSelectors([]string{selector1, selector2}) if err != nil { t.Errorf("Test error for Desc: %s. Can't merge field selector %v.", test.Desc, err) diff --git a/tests/e2e.sh b/tests/e2e.sh index 8a8773d4b0..a07ba20f36 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -124,10 +124,7 @@ function test_daemonset() { sed -i "s|${KUBE_STATE_METRICS_CURRENT_IMAGE_NAME}:v.*|${KUBE_STATE_METRICS_IMAGE_NAME}:${KUBE_STATE_METRICS_IMAGE_TAG}|g" ./examples/daemonsetsharding/daemonset.yaml sed -i "s|${KUBE_STATE_METRICS_CURRENT_IMAGE_NAME}:v.*|${KUBE_STATE_METRICS_IMAGE_NAME}:${KUBE_STATE_METRICS_IMAGE_TAG}|g" ./examples/daemonsetsharding/deployment-no-node-pods.yaml - cat ./examples/daemonsetsharding/deployment-no-node-pods.yaml - sleep 3 kubectl get deployment -n kube-system - ls ./examples/daemonsetsharding kubectl create -f ./examples/daemonsetsharding kube_state_metrics_up kube-state-metrics-no-node-pods kube_state_metrics_up kube-state-metrics @@ -137,12 +134,6 @@ function test_daemonset() { kube_pod_up pendingpod2 kubectl get deployment -n default - # curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-shard:http-metrics/proxy/metrics" >${KUBE_STATE_METRICS_LOG_DIR}/daemonset-scraped-metrics - # curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:http-metrics/proxy/metrics" >${KUBE_STATE_METRICS_LOG_DIR}/deployment-scraped-metrics - # curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-no-node-pods:http-metrics/proxy/metrics" >${KUBE_STATE_METRICS_LOG_DIR}/deployment-scraped-no-node-metrics - - # cat ${KUBE_STATE_METRICS_LOG_DIR}/daemonset-scraped-metrics ${KUBE_STATE_METRICS_LOG_DIR}/deployment-scraped-metrics ${KUBE_STATE_METRICS_LOG_DIR}/deployment-scraped-no-node-metrics >> ${KUBE_STATE_METRICS_LOG_DIR}/all-metrics - # cat ${KUBE_STATE_METRICS_LOG_DIR}/all-metrics | grep "kube_pod_info" runningpod1="$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-shard:http-metrics/proxy/metrics" | grep "runningpod1" | grep -c "kube_pod_info" )" node1="$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:http-metrics/proxy/metrics" | grep -c "# TYPE kube_node_info" )" expected_num_pod=1 @@ -157,11 +148,9 @@ function test_daemonset() { fi kubectl logs deployment/kube-state-metrics-no-node-pods -n kube-system - sleep 3 - curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-no-node-pods:http-metrics/proxy/metrics" - sleep 3 + sleep 2 kubectl get pods -A --field-selector spec.nodeName="" - sleep 3 + sleep 2 pendingpod2="$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-no-node-pods:http-metrics/proxy/metrics" | grep "pendingpod2" | grep -c "kube_pod_info" )" if [ "${pendingpod2}" != "${expected_num_pod}" ]; then echo "metric kube_pod_info for pendingpod2 doesn't show up only once, got ${runningpod1} times" @@ -244,6 +233,8 @@ echo "kube-state-metrics is up and running" echo "start e2e test for kube-state-metrics" KSM_HTTP_METRICS_URL='http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:http-metrics/proxy' KSM_TELEMETRY_URL='http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:telemetry/proxy' + +kubectl --namespace=kube-system logs deployment/kube-state-metrics kube-state-metrics go test -v ./tests/e2e/main_test.go --ksm-http-metrics-url=${KSM_HTTP_METRICS_URL} --ksm-telemetry-url=${KSM_TELEMETRY_URL} # TODO: re-implement the following test cases in Go with the goal of removing this file. diff --git a/tests/e2e/testdata/pods.yaml b/tests/e2e/testdata/pods.yaml index 523e7b3317..f3b14b21a2 100644 --- a/tests/e2e/testdata/pods.yaml +++ b/tests/e2e/testdata/pods.yaml @@ -26,7 +26,7 @@ spec: - command: - /agnhost - netexec - - --http-port=8080q + - --http-port=8080 image: registry.k8s.io/e2e-test-images/agnhost:2.39 imagePullPolicy: IfNotPresent name: agnhost From 49e1170f673b272781d00dcc334d16df5f444a76 Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Thu, 13 Jun 2024 11:25:37 -0400 Subject: [PATCH 054/154] rename to --fetch-unscheduled-pods --- README.md | 4 ++-- README.md.tpl | 4 ++-- docs/developer/cli-arguments.md | 2 +- examples/daemonsetsharding/deployment-no-node-pods.yaml | 2 +- jsonnet/kube-state-metrics/kube-state-metrics.libsonnet | 4 ++-- pkg/app/server.go | 2 +- pkg/options/options.go | 4 ++-- tests/e2e.sh | 4 ---- tests/e2e/testdata/pods.yaml | 4 ++-- 9 files changed, 13 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index adf5433620..221e64940c 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--enable-no-node-scrape`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--fetch-unscheduled-pods`, as shown in the following example: ``` apiVersion: apps/v1 @@ -295,7 +295,7 @@ spec: name: kube-state-metrics args: - --resources=pods - - --enable-no-node-scrape + - --fetch-unscheduled-pods ``` Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding). diff --git a/README.md.tpl b/README.md.tpl index a68c47bf21..6b4f87e2a7 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -283,7 +283,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--enable-no-node-scrape`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--fetch-unscheduled-pods`, as shown in the following example: ``` apiVersion: apps/v1 @@ -296,7 +296,7 @@ spec: name: kube-state-metrics args: - --resources=pods - - --enable-no-node-scrape + - --fetch-unscheduled-pods ``` Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding). diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index 35b25e5ffd..55b7b54b4f 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -48,7 +48,7 @@ Flags: --custom-resource-state-config-file string Path to a Custom Resource State Metrics config file (experimental) --custom-resource-state-only Only provide Custom Resource State metrics (experimental) --enable-gzip-encoding Gzip responses when requested by clients via 'Accept-Encoding: gzip' header. - --enable-no-node-scrape This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental. + --fetch-unscheduled-pods This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental. -h, --help Print Help text --host string Host to expose metrics on. (default "::") --kubeconfig string Absolute path to the kubeconfig file diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index 50fc840afa..5446838ca2 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -23,7 +23,7 @@ spec: containers: - args: - --resources=pods - - --enable-no-node-scrape + - --fetch-unscheduled-pods image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 livenessProbe: httpGet: diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index 7ac9f71fe9..ff05112885 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -377,7 +377,7 @@ local c = ksm.deployment.spec.template.spec.containers[0] { args: [ '--resources=pods', - '--enable-no-node-scrape', + '--fetch-unscheduled-pods', ], name: shardksmname, }; @@ -410,7 +410,7 @@ local c = ksm.deployment.spec.template.spec.containers[0] { args: [ '--resources=pods', - '--enable-no-node-scrape', + '--fetch-unscheduled-pods', ], }; local shardksmname = ksm.name + "-no-node-pods"; diff --git a/pkg/app/server.go b/pkg/app/server.go index 194c0676bb..f2c09d633f 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -224,7 +224,7 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { namespaces := opts.Namespaces.GetNamespaces() nsFieldSelector := namespaces.GetExcludeNSFieldSelector(opts.NamespacesDenylist) - nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.EnableNoNodeScrape) + nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.FetchUnscheduledPods) merged, err := storeBuilder.MergeFieldSelectors([]string{nsFieldSelector, nodeFieldSelector}) if err != nil { return err diff --git a/pkg/options/options.go b/pkg/options/options.go index 5899211b66..a1edb0f22b 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -59,7 +59,7 @@ type Options struct { Namespaces NamespaceList `yaml:"namespaces"` NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"` Node NodeType `yaml:"node"` - EnableNoNodeScrape bool `yaml:"enable_no_node_scrape"` + FetchUnscheduledPods bool `yaml:"fetch_unscheduled_pods"` Pod string `yaml:"pod"` Port int `yaml:"port"` Resources ResourceSet `yaml:"resources"` @@ -138,7 +138,7 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().BoolVar(&o.CustomResourcesOnly, "custom-resource-state-only", false, "Only provide Custom Resource State metrics (experimental)") o.cmd.Flags().BoolVar(&o.EnableGZIPEncoding, "enable-gzip-encoding", false, "Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.") - o.cmd.Flags().BoolVar(&o.EnableNoNodeScrape, "enable-no-node-scrape", false, "This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental.") + o.cmd.Flags().BoolVar(&o.FetchUnscheduledPods, "fetch-unscheduled-pods", false, "This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental.") o.cmd.Flags().BoolVarP(&o.Help, "help", "h", false, "Print Help text") o.cmd.Flags().BoolVarP(&o.UseAPIServerCache, "use-apiserver-cache", "", false, "Sets resourceVersion=0 for ListWatch requests, using cached resources from the apiserver instead of an etcd quorum read.") o.cmd.Flags().Int32Var(&o.Shard, "shard", int32(0), "The instances shard nominal (zero indexed) within the total number of shards. (default 0)") diff --git a/tests/e2e.sh b/tests/e2e.sh index a07ba20f36..be25eb8060 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -187,9 +187,6 @@ set -e kubectl version # query kube-state-metrics image tag -cat pkg/options/types.go -sleep 3 - REGISTRY="registry.k8s.io/kube-state-metrics" make container docker images -a KUBE_STATE_METRICS_IMAGE_TAG=$(docker images -a|grep "${KUBE_STATE_METRICS_IMAGE_NAME}" |grep -v 'latest'|awk '{print $2}'|sort -u) @@ -234,7 +231,6 @@ echo "start e2e test for kube-state-metrics" KSM_HTTP_METRICS_URL='http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:http-metrics/proxy' KSM_TELEMETRY_URL='http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics:telemetry/proxy' -kubectl --namespace=kube-system logs deployment/kube-state-metrics kube-state-metrics go test -v ./tests/e2e/main_test.go --ksm-http-metrics-url=${KSM_HTTP_METRICS_URL} --ksm-telemetry-url=${KSM_TELEMETRY_URL} # TODO: re-implement the following test cases in Go with the goal of removing this file. diff --git a/tests/e2e/testdata/pods.yaml b/tests/e2e/testdata/pods.yaml index f3b14b21a2..c2e45f1668 100644 --- a/tests/e2e/testdata/pods.yaml +++ b/tests/e2e/testdata/pods.yaml @@ -27,7 +27,7 @@ spec: - /agnhost - netexec - --http-port=8080 - image: registry.k8s.io/e2e-test-images/agnhost:2.39 + image: registry.k8s.io/e2e-test-images/agnhost@sha256:7e8bdd271312fd25fc5ff5a8f04727be84044eb3d7d8d03611972a6752e2e11e # 2.39 imagePullPolicy: IfNotPresent name: agnhost terminationMessagePath: /dev/termination-log @@ -64,7 +64,7 @@ spec: - /agnhost - netexec - --http-port=8080 - image: registry.k8s.io/e2e-test-images/agnhost:2.39 + image: registry.k8s.io/e2e-test-images/agnhost@sha256:7e8bdd271312fd25fc5ff5a8f04727be84044eb3d7d8d03611972a6752e2e11e # 2.39 imagePullPolicy: IfNotPresent name: agnhost terminationMessagePath: /dev/termination-log From 85f8a2c4cc9339288fa78e923127faab1fa97d25 Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Thu, 13 Jun 2024 12:46:48 -0400 Subject: [PATCH 055/154] rename to --enable-unscheduled-pods-fetching --- README.md | 4 ++-- README.md.tpl | 4 ++-- docs/developer/cli-arguments.md | 2 +- examples/daemonsetsharding/deployment-no-node-pods.yaml | 2 +- jsonnet/kube-state-metrics/kube-state-metrics.libsonnet | 4 ++-- pkg/app/server.go | 2 +- pkg/options/options.go | 4 ++-- pkg/options/types.go | 3 +++ pkg/options/types_test.go | 5 +++++ 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 221e64940c..907d37f394 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--fetch-unscheduled-pods`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--enable-unscheduled-pods-fetching`, as shown in the following example: ``` apiVersion: apps/v1 @@ -295,7 +295,7 @@ spec: name: kube-state-metrics args: - --resources=pods - - --fetch-unscheduled-pods + - --enable-unscheduled-pods-fetching ``` Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding). diff --git a/README.md.tpl b/README.md.tpl index 6b4f87e2a7..325229486f 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -283,7 +283,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--fetch-unscheduled-pods`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--enable-unscheduled-pods-fetching`, as shown in the following example: ``` apiVersion: apps/v1 @@ -296,7 +296,7 @@ spec: name: kube-state-metrics args: - --resources=pods - - --fetch-unscheduled-pods + - --enable-unscheduled-pods-fetching ``` Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding). diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index 55b7b54b4f..d840f5f2a5 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -48,7 +48,7 @@ Flags: --custom-resource-state-config-file string Path to a Custom Resource State Metrics config file (experimental) --custom-resource-state-only Only provide Custom Resource State metrics (experimental) --enable-gzip-encoding Gzip responses when requested by clients via 'Accept-Encoding: gzip' header. - --fetch-unscheduled-pods This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental. + --enable-unscheduled-pods-fetching This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental. -h, --help Print Help text --host string Host to expose metrics on. (default "::") --kubeconfig string Absolute path to the kubeconfig file diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index 5446838ca2..c1516b9343 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -23,7 +23,7 @@ spec: containers: - args: - --resources=pods - - --fetch-unscheduled-pods + - --enable-unscheduled-pods-fetching image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 livenessProbe: httpGet: diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index ff05112885..7bc90f71ca 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -377,7 +377,7 @@ local c = ksm.deployment.spec.template.spec.containers[0] { args: [ '--resources=pods', - '--fetch-unscheduled-pods', + '--enable-unscheduled-pods-fetching', ], name: shardksmname, }; @@ -410,7 +410,7 @@ local c = ksm.deployment.spec.template.spec.containers[0] { args: [ '--resources=pods', - '--fetch-unscheduled-pods', + '--enable-unscheduled-pods-fetching', ], }; local shardksmname = ksm.name + "-no-node-pods"; diff --git a/pkg/app/server.go b/pkg/app/server.go index f2c09d633f..890e1fc6d2 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -224,7 +224,7 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { namespaces := opts.Namespaces.GetNamespaces() nsFieldSelector := namespaces.GetExcludeNSFieldSelector(opts.NamespacesDenylist) - nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.FetchUnscheduledPods) + nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.EnableUnscheduledPodsFetching) merged, err := storeBuilder.MergeFieldSelectors([]string{nsFieldSelector, nodeFieldSelector}) if err != nil { return err diff --git a/pkg/options/options.go b/pkg/options/options.go index a1edb0f22b..9e155dfe1f 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -59,7 +59,7 @@ type Options struct { Namespaces NamespaceList `yaml:"namespaces"` NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"` Node NodeType `yaml:"node"` - FetchUnscheduledPods bool `yaml:"fetch_unscheduled_pods"` + EnableUnscheduledPodsFetching bool `yaml:"enable_unscheduled_pods_fetching"` Pod string `yaml:"pod"` Port int `yaml:"port"` Resources ResourceSet `yaml:"resources"` @@ -138,7 +138,7 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().BoolVar(&o.CustomResourcesOnly, "custom-resource-state-only", false, "Only provide Custom Resource State metrics (experimental)") o.cmd.Flags().BoolVar(&o.EnableGZIPEncoding, "enable-gzip-encoding", false, "Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.") - o.cmd.Flags().BoolVar(&o.FetchUnscheduledPods, "fetch-unscheduled-pods", false, "This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental.") + o.cmd.Flags().BoolVar(&o.EnableUnscheduledPodsFetching, "enable-unscheduled-pods-fetching", false, "This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental.") o.cmd.Flags().BoolVarP(&o.Help, "help", "h", false, "Print Help text") o.cmd.Flags().BoolVarP(&o.UseAPIServerCache, "use-apiserver-cache", "", false, "Sets resourceVersion=0 for ListWatch requests, using cached resources from the apiserver instead of an etcd quorum read.") o.cmd.Flags().Int32Var(&o.Shard, "shard", int32(0), "The instances shard nominal (zero indexed) within the total number of shards. (default 0)") diff --git a/pkg/options/types.go b/pkg/options/types.go index 61579d810b..41cfeabc62 100644 --- a/pkg/options/types.go +++ b/pkg/options/types.go @@ -110,6 +110,9 @@ type NodeType string // GetNodeFieldSelector returns a nodename field selector. func (n *NodeType) GetNodeFieldSelector(noNodeAssigned bool) string { if noNodeAssigned { + if string(*n) != "" { + klog.Warningf("spec.nodeName=%s will not be used, because --enable-unscheduled-pods-fetching is set", string(*n)) + } klog.InfoS("Using spec.nodeName= to select unscheduable pods without node") return "spec.nodeName=" } diff --git a/pkg/options/types_test.go b/pkg/options/types_test.go index 96ec0675bc..3fc6df1825 100644 --- a/pkg/options/types_test.go +++ b/pkg/options/types_test.go @@ -190,6 +190,11 @@ func TestNodeFieldSelector(t *testing.T) { Node: "", Wanted: "spec.nodeName=", }, + { + Desc: "have node name when --enable-unscheduled-pods-fetching is set", + Node: "", + Wanted: "spec.nodeName=", + }, } for _, test := range tests1 { node := test.Node From 4a524950f17b2b68ebedd52dae9791058589e7d7 Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Fri, 14 Jun 2024 07:48:12 -0400 Subject: [PATCH 056/154] Update pkg/options/types.go Co-authored-by: Alex Kennedy --- pkg/options/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/options/types.go b/pkg/options/types.go index 41cfeabc62..08f3d18bd6 100644 --- a/pkg/options/types.go +++ b/pkg/options/types.go @@ -108,8 +108,8 @@ func (r *ResourceSet) Type() string { type NodeType string // GetNodeFieldSelector returns a nodename field selector. -func (n *NodeType) GetNodeFieldSelector(noNodeAssigned bool) string { - if noNodeAssigned { +func (n *NodeType) GetNodeFieldSelector(fetchUnscheduledPods bool) string { + if fetchUnscheduledPods { if string(*n) != "" { klog.Warningf("spec.nodeName=%s will not be used, because --enable-unscheduled-pods-fetching is set", string(*n)) } From bb5a37c6e917e689be59c0971dd25043a8d1972e Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Fri, 14 Jun 2024 07:48:25 -0400 Subject: [PATCH 057/154] Update jsonnet/kube-state-metrics/kube-state-metrics.libsonnet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Manuel Rüger --- jsonnet/kube-state-metrics/kube-state-metrics.libsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index 7bc90f71ca..30b57b6a17 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -381,7 +381,7 @@ ], name: shardksmname, }; - local shardksmname = ksm.name + "-no-node-pods"; + local shardksmname = ksm.name + "-unscheduled-pods-fetching"; std.mergePatch(ksm.deployment, { metadata: { From c9ceded7247ef537db62c1795788243c4da87e4b Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Fri, 14 Jun 2024 07:48:41 -0400 Subject: [PATCH 058/154] Update docs/developer/cli-arguments.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Manuel Rüger --- docs/developer/cli-arguments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index d840f5f2a5..a134d82654 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -48,7 +48,7 @@ Flags: --custom-resource-state-config-file string Path to a Custom Resource State Metrics config file (experimental) --custom-resource-state-only Only provide Custom Resource State metrics (experimental) --enable-gzip-encoding Gzip responses when requested by clients via 'Accept-Encoding: gzip' header. - --enable-unscheduled-pods-fetching This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental. + --enable-unscheduled-pods-fetching This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of unscheduled pods is fetched from the Kubernetes API Server. This is experimental. -h, --help Print Help text --host string Host to expose metrics on. (default "::") --kubeconfig string Absolute path to the kubeconfig file From 19a0544f4477438518efd66b3a2c0d14d3a3de65 Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Fri, 14 Jun 2024 08:01:40 -0400 Subject: [PATCH 059/154] update doc --- pkg/options/options.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/options/options.go b/pkg/options/options.go index 9e155dfe1f..fd097bc7a9 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -60,19 +60,19 @@ type Options struct { NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"` Node NodeType `yaml:"node"` EnableUnscheduledPodsFetching bool `yaml:"enable_unscheduled_pods_fetching"` - Pod string `yaml:"pod"` - Port int `yaml:"port"` - Resources ResourceSet `yaml:"resources"` - Shard int32 `yaml:"shard"` - TLSConfig string `yaml:"tls_config"` - TelemetryHost string `yaml:"telemetry_host"` - TelemetryPort int `yaml:"telemetry_port"` - TotalShards int `yaml:"total_shards"` - UseAPIServerCache bool `yaml:"use_api_server_cache"` - ServerReadTimeout time.Duration `yaml:"server_read_timeout"` - ServerWriteTimeout time.Duration `yaml:"server_write_timeout"` - ServerIdleTimeout time.Duration `yaml:"server_idle_timeout"` - ServerReadHeaderTimeout time.Duration `yaml:"server_read_header_timeout"` + Pod string `yaml:"pod"` + Port int `yaml:"port"` + Resources ResourceSet `yaml:"resources"` + Shard int32 `yaml:"shard"` + TLSConfig string `yaml:"tls_config"` + TelemetryHost string `yaml:"telemetry_host"` + TelemetryPort int `yaml:"telemetry_port"` + TotalShards int `yaml:"total_shards"` + UseAPIServerCache bool `yaml:"use_api_server_cache"` + ServerReadTimeout time.Duration `yaml:"server_read_timeout"` + ServerWriteTimeout time.Duration `yaml:"server_write_timeout"` + ServerIdleTimeout time.Duration `yaml:"server_idle_timeout"` + ServerReadHeaderTimeout time.Duration `yaml:"server_read_header_timeout"` Config string @@ -138,7 +138,7 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().BoolVar(&o.CustomResourcesOnly, "custom-resource-state-only", false, "Only provide Custom Resource State metrics (experimental)") o.cmd.Flags().BoolVar(&o.EnableGZIPEncoding, "enable-gzip-encoding", false, "Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.") - o.cmd.Flags().BoolVar(&o.EnableUnscheduledPodsFetching, "enable-unscheduled-pods-fetching", false, "This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of no scheduled pods is scraped. This is experimental.") + o.cmd.Flags().BoolVar(&o.EnableUnscheduledPodsFetching, "enable-unscheduled-pods-fetching", false, "This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of unscheduled pods is fetched from the Kubernetes API Server. This is experimental.") o.cmd.Flags().BoolVarP(&o.Help, "help", "h", false, "Print Help text") o.cmd.Flags().BoolVarP(&o.UseAPIServerCache, "use-apiserver-cache", "", false, "Sets resourceVersion=0 for ListWatch requests, using cached resources from the apiserver instead of an etcd quorum read.") o.cmd.Flags().Int32Var(&o.Shard, "shard", int32(0), "The instances shard nominal (zero indexed) within the total number of shards. (default 0)") From eda1984438d040e18f26c3bd2538409f4242ff75 Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Fri, 28 Jun 2024 15:04:40 -0400 Subject: [PATCH 060/154] Rename --enable-unscheduled-pods-fetching to --track-unscheduled-pods --- README.md | 4 ++-- README.md.tpl | 4 ++-- docs/developer/cli-arguments.md | 2 +- examples/daemonsetsharding/deployment-no-node-pods.yaml | 2 +- jsonnet/kube-state-metrics/kube-state-metrics.libsonnet | 4 ++-- pkg/app/server.go | 2 +- pkg/options/options.go | 4 ++-- pkg/options/types.go | 2 +- pkg/options/types_test.go | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 907d37f394..993a9bdb11 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--enable-unscheduled-pods-fetching`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--track-unscheduled-pods`, as shown in the following example: ``` apiVersion: apps/v1 @@ -295,7 +295,7 @@ spec: name: kube-state-metrics args: - --resources=pods - - --enable-unscheduled-pods-fetching + - --track-unscheduled-pods ``` Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding). diff --git a/README.md.tpl b/README.md.tpl index 325229486f..a41d8bdc1d 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -283,7 +283,7 @@ spec: fieldPath: spec.nodeName ``` -To track metrics for unassigned pods, you need to add an additional deployment and set `--enable-unscheduled-pods-fetching`, as shown in the following example: +To track metrics for unassigned pods, you need to add an additional deployment and set `--track-unscheduled-pods`, as shown in the following example: ``` apiVersion: apps/v1 @@ -296,7 +296,7 @@ spec: name: kube-state-metrics args: - --resources=pods - - --enable-unscheduled-pods-fetching + - --track-unscheduled-pods ``` Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding). diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index a134d82654..5328e05079 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -48,7 +48,7 @@ Flags: --custom-resource-state-config-file string Path to a Custom Resource State Metrics config file (experimental) --custom-resource-state-only Only provide Custom Resource State metrics (experimental) --enable-gzip-encoding Gzip responses when requested by clients via 'Accept-Encoding: gzip' header. - --enable-unscheduled-pods-fetching This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of unscheduled pods is fetched from the Kubernetes API Server. This is experimental. + --track-unscheduled-pods This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of unscheduled pods is fetched from the Kubernetes API Server. This is experimental. -h, --help Print Help text --host string Host to expose metrics on. (default "::") --kubeconfig string Absolute path to the kubeconfig file diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index c1516b9343..eac87a53ca 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -23,7 +23,7 @@ spec: containers: - args: - --resources=pods - - --enable-unscheduled-pods-fetching + - --track-unscheduled-pods image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 livenessProbe: httpGet: diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index 30b57b6a17..13bef45541 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -377,7 +377,7 @@ local c = ksm.deployment.spec.template.spec.containers[0] { args: [ '--resources=pods', - '--enable-unscheduled-pods-fetching', + '--track-unscheduled-pods', ], name: shardksmname, }; @@ -410,7 +410,7 @@ local c = ksm.deployment.spec.template.spec.containers[0] { args: [ '--resources=pods', - '--enable-unscheduled-pods-fetching', + '--track-unscheduled-pods', ], }; local shardksmname = ksm.name + "-no-node-pods"; diff --git a/pkg/app/server.go b/pkg/app/server.go index 890e1fc6d2..8dbcf1d409 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -224,7 +224,7 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { namespaces := opts.Namespaces.GetNamespaces() nsFieldSelector := namespaces.GetExcludeNSFieldSelector(opts.NamespacesDenylist) - nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.EnableUnscheduledPodsFetching) + nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.TrackUnscheduledPods) merged, err := storeBuilder.MergeFieldSelectors([]string{nsFieldSelector, nodeFieldSelector}) if err != nil { return err diff --git a/pkg/options/options.go b/pkg/options/options.go index fd097bc7a9..3e1b67f9cc 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -59,7 +59,7 @@ type Options struct { Namespaces NamespaceList `yaml:"namespaces"` NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"` Node NodeType `yaml:"node"` - EnableUnscheduledPodsFetching bool `yaml:"enable_unscheduled_pods_fetching"` + TrackUnscheduledPods bool `yaml:"track_unscheduled_pods"` Pod string `yaml:"pod"` Port int `yaml:"port"` Resources ResourceSet `yaml:"resources"` @@ -138,7 +138,7 @@ func (o *Options) AddFlags(cmd *cobra.Command) { o.cmd.Flags().BoolVar(&o.CustomResourcesOnly, "custom-resource-state-only", false, "Only provide Custom Resource State metrics (experimental)") o.cmd.Flags().BoolVar(&o.EnableGZIPEncoding, "enable-gzip-encoding", false, "Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.") - o.cmd.Flags().BoolVar(&o.EnableUnscheduledPodsFetching, "enable-unscheduled-pods-fetching", false, "This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of unscheduled pods is fetched from the Kubernetes API Server. This is experimental.") + o.cmd.Flags().BoolVar(&o.TrackUnscheduledPods, "track-unscheduled-pods", false, "This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of unscheduled pods is fetched from the Kubernetes API Server. This is experimental.") o.cmd.Flags().BoolVarP(&o.Help, "help", "h", false, "Print Help text") o.cmd.Flags().BoolVarP(&o.UseAPIServerCache, "use-apiserver-cache", "", false, "Sets resourceVersion=0 for ListWatch requests, using cached resources from the apiserver instead of an etcd quorum read.") o.cmd.Flags().Int32Var(&o.Shard, "shard", int32(0), "The instances shard nominal (zero indexed) within the total number of shards. (default 0)") diff --git a/pkg/options/types.go b/pkg/options/types.go index 08f3d18bd6..d1173e2eea 100644 --- a/pkg/options/types.go +++ b/pkg/options/types.go @@ -111,7 +111,7 @@ type NodeType string func (n *NodeType) GetNodeFieldSelector(fetchUnscheduledPods bool) string { if fetchUnscheduledPods { if string(*n) != "" { - klog.Warningf("spec.nodeName=%s will not be used, because --enable-unscheduled-pods-fetching is set", string(*n)) + klog.Warningf("spec.nodeName=%s will not be used, because --track-unscheduled-pods is set", string(*n)) } klog.InfoS("Using spec.nodeName= to select unscheduable pods without node") return "spec.nodeName=" diff --git a/pkg/options/types_test.go b/pkg/options/types_test.go index 3fc6df1825..44fb26ec7c 100644 --- a/pkg/options/types_test.go +++ b/pkg/options/types_test.go @@ -191,7 +191,7 @@ func TestNodeFieldSelector(t *testing.T) { Wanted: "spec.nodeName=", }, { - Desc: "have node name when --enable-unscheduled-pods-fetching is set", + Desc: "have node name when --track-unscheduled-pods is set", Node: "", Wanted: "spec.nodeName=", }, From e18b5573ac4963559810e362a7356049690ec1a3 Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Tue, 2 Jul 2024 09:54:31 -0400 Subject: [PATCH 061/154] format --- docs/developer/cli-arguments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer/cli-arguments.md b/docs/developer/cli-arguments.md index 5328e05079..be402db950 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -48,7 +48,6 @@ Flags: --custom-resource-state-config-file string Path to a Custom Resource State Metrics config file (experimental) --custom-resource-state-only Only provide Custom Resource State metrics (experimental) --enable-gzip-encoding Gzip responses when requested by clients via 'Accept-Encoding: gzip' header. - --track-unscheduled-pods This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of unscheduled pods is fetched from the Kubernetes API Server. This is experimental. -h, --help Print Help text --host string Host to expose metrics on. (default "::") --kubeconfig string Absolute path to the kubeconfig file @@ -82,6 +81,7 @@ Flags: --telemetry-port int Port to expose kube-state-metrics self metrics on. (default 8081) --tls-config string Path to the TLS configuration file --total-shards int The total number of shards. Sharding is disabled when total shards is set to 1. (default 1) + --track-unscheduled-pods This configuration is used in conjunction with node configuration. When this configuration is true, node configuration is empty and the metric of unscheduled pods is fetched from the Kubernetes API Server. This is experimental. --use-apiserver-cache Sets resourceVersion=0 for ListWatch requests, using cached resources from the apiserver instead of an etcd quorum read. -v, --v Level number for the log level verbosity --vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging From aeb9e355b5355aeebd3428b3d65af02e2607a646 Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Tue, 16 Jul 2024 20:33:58 -0400 Subject: [PATCH 062/154] Fix Nodetype --- pkg/app/server.go | 8 +++++++- pkg/options/options.go | 26 +++++++++++++------------- pkg/options/types.go | 20 ++++++++++++-------- pkg/options/types_test.go | 27 ++------------------------- 4 files changed, 34 insertions(+), 47 deletions(-) diff --git a/pkg/app/server.go b/pkg/app/server.go index 8dbcf1d409..98bb11df01 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -224,7 +224,13 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { namespaces := opts.Namespaces.GetNamespaces() nsFieldSelector := namespaces.GetExcludeNSFieldSelector(opts.NamespacesDenylist) - nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.TrackUnscheduledPods) + var nodeFieldSelector string + if opts.TrackUnscheduledPods { + nodeFieldSelector = "spec.nodeName=" + klog.InfoS("Using spec.nodeName= to select unscheduable pods without node") + } else { + nodeFieldSelector = opts.Node.GetNodeFieldSelector() + } merged, err := storeBuilder.MergeFieldSelectors([]string{nsFieldSelector, nodeFieldSelector}) if err != nil { return err diff --git a/pkg/options/options.go b/pkg/options/options.go index 3e1b67f9cc..d10a12cce2 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -60,19 +60,19 @@ type Options struct { NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"` Node NodeType `yaml:"node"` TrackUnscheduledPods bool `yaml:"track_unscheduled_pods"` - Pod string `yaml:"pod"` - Port int `yaml:"port"` - Resources ResourceSet `yaml:"resources"` - Shard int32 `yaml:"shard"` - TLSConfig string `yaml:"tls_config"` - TelemetryHost string `yaml:"telemetry_host"` - TelemetryPort int `yaml:"telemetry_port"` - TotalShards int `yaml:"total_shards"` - UseAPIServerCache bool `yaml:"use_api_server_cache"` - ServerReadTimeout time.Duration `yaml:"server_read_timeout"` - ServerWriteTimeout time.Duration `yaml:"server_write_timeout"` - ServerIdleTimeout time.Duration `yaml:"server_idle_timeout"` - ServerReadHeaderTimeout time.Duration `yaml:"server_read_header_timeout"` + Pod string `yaml:"pod"` + Port int `yaml:"port"` + Resources ResourceSet `yaml:"resources"` + Shard int32 `yaml:"shard"` + TLSConfig string `yaml:"tls_config"` + TelemetryHost string `yaml:"telemetry_host"` + TelemetryPort int `yaml:"telemetry_port"` + TotalShards int `yaml:"total_shards"` + UseAPIServerCache bool `yaml:"use_api_server_cache"` + ServerReadTimeout time.Duration `yaml:"server_read_timeout"` + ServerWriteTimeout time.Duration `yaml:"server_write_timeout"` + ServerIdleTimeout time.Duration `yaml:"server_idle_timeout"` + ServerReadHeaderTimeout time.Duration `yaml:"server_read_header_timeout"` Config string diff --git a/pkg/options/types.go b/pkg/options/types.go index d1173e2eea..93f8a7f505 100644 --- a/pkg/options/types.go +++ b/pkg/options/types.go @@ -107,15 +107,19 @@ func (r *ResourceSet) Type() string { // NodeType represents a nodeName to query from. type NodeType string +// Set sets the node name to NodeType. +func (n *NodeType) Set(value string) error { + *n = NodeType(value) + return nil +} + +// String gets node name. +func (n NodeType) String() string { + return string(n) +} + // GetNodeFieldSelector returns a nodename field selector. -func (n *NodeType) GetNodeFieldSelector(fetchUnscheduledPods bool) string { - if fetchUnscheduledPods { - if string(*n) != "" { - klog.Warningf("spec.nodeName=%s will not be used, because --track-unscheduled-pods is set", string(*n)) - } - klog.InfoS("Using spec.nodeName= to select unscheduable pods without node") - return "spec.nodeName=" - } +func (n *NodeType) GetNodeFieldSelector() string { if string(*n) != "" { return fields.OneTermEqualSelector("spec.nodeName", string(*n)).String() } diff --git a/pkg/options/types_test.go b/pkg/options/types_test.go index 44fb26ec7c..a1b43a2c0b 100644 --- a/pkg/options/types_test.go +++ b/pkg/options/types_test.go @@ -175,30 +175,7 @@ func TestNodeFieldSelector(t *testing.T) { for _, test := range tests { node := test.Node - actual := node.GetNodeFieldSelector(false) - if !reflect.DeepEqual(actual, test.Wanted) { - t.Errorf("Test error for Desc: %s. Want: %+v. Got: %+v.", test.Desc, test.Wanted, actual) - } - } - tests1 := []struct { - Desc string - Node NodeType - Wanted string - }{ - { - Desc: "empty node name", - Node: "", - Wanted: "spec.nodeName=", - }, - { - Desc: "have node name when --track-unscheduled-pods is set", - Node: "", - Wanted: "spec.nodeName=", - }, - } - for _, test := range tests1 { - node := test.Node - actual := node.GetNodeFieldSelector(true) + actual := node.GetNodeFieldSelector() if !reflect.DeepEqual(actual, test.Wanted) { t.Errorf("Test error for Desc: %s. Want: %+v. Got: %+v.", test.Desc, test.Wanted, actual) } @@ -261,7 +238,7 @@ func TestMergeFieldSelectors(t *testing.T) { ns := test.Namespaces deniedNS := test.DeniedNamespaces selector1 := ns.GetExcludeNSFieldSelector(deniedNS) - selector2 := test.Node.GetNodeFieldSelector(false) + selector2 := test.Node.GetNodeFieldSelector() actual, err := MergeFieldSelectors([]string{selector1, selector2}) if err != nil { t.Errorf("Test error for Desc: %s. Can't merge field selector %v.", test.Desc, err) From 0dd960eb3104f1eca3393cba0c75d33a344431ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 26 Jul 2024 13:56:17 +0200 Subject: [PATCH 063/154] Dockerfile: Install tools so VERSION gets set --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d8899a7ae3..c6b5e6ef65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ ENV GOARCH=${GOARCH} WORKDIR /go/src/k8s.io/kube-state-metrics/ COPY . /go/src/k8s.io/kube-state-metrics/ -RUN make build-local +RUN make install-tools && make build-local FROM gcr.io/distroless/static:latest-${GOARCH} COPY --from=builder /go/src/k8s.io/kube-state-metrics/kube-state-metrics / From cc79a584115671f2a7fe172e2adaef57032f0084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 5 Aug 2024 16:12:38 +0200 Subject: [PATCH 064/154] chore: Avoid naked return --- pkg/watch/watch.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/watch/watch.go b/pkg/watch/watch.go index 751097caaa..48fe2bcc11 100644 --- a/pkg/watch/watch.go +++ b/pkg/watch/watch.go @@ -74,31 +74,31 @@ func NewInstrumentedListerWatcher(lw cache.ListerWatcher, metrics *ListWatchMetr // List is a wrapper func around the cache.ListerWatcher.List func. It increases the success/error // / counters based on the outcome of the List operation it instruments. -func (i *InstrumentedListerWatcher) List(options metav1.ListOptions) (res runtime.Object, err error) { +func (i *InstrumentedListerWatcher) List(options metav1.ListOptions) (runtime.Object, error) { if i.useAPIServerCache { options.ResourceVersion = "0" } - res, err = i.lw.List(options) + res, err := i.lw.List(options) if err != nil { i.metrics.ListTotal.WithLabelValues("error", i.resource).Inc() - return + return nil, err } i.metrics.ListTotal.WithLabelValues("success", i.resource).Inc() - return + return res, nil } // Watch is a wrapper func around the cache.ListerWatcher.Watch func. It increases the success/error // counters based on the outcome of the Watch operation it instruments. -func (i *InstrumentedListerWatcher) Watch(options metav1.ListOptions) (res watch.Interface, err error) { - res, err = i.lw.Watch(options) +func (i *InstrumentedListerWatcher) Watch(options metav1.ListOptions) (watch.Interface, error) { + res, err := i.lw.Watch(options) if err != nil { i.metrics.WatchTotal.WithLabelValues("error", i.resource).Inc() - return + return nil, err } i.metrics.WatchTotal.WithLabelValues("success", i.resource).Inc() - return + return res, nil } From 74d226ccf04f529e470900e7a268528ed82ef23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 5 Aug 2024 16:44:43 +0200 Subject: [PATCH 065/154] chore: Replace NewReflector with NewReflectorWithOptions func --- internal/store/builder.go | 2 +- tests/lib/lib_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/store/builder.go b/internal/store/builder.go index 5c38857d7b..db4e06baa9 100644 --- a/internal/store/builder.go +++ b/internal/store/builder.go @@ -603,7 +603,7 @@ func (b *Builder) startReflector( useAPIServerCache bool, ) { instrumentedListWatch := watch.NewInstrumentedListerWatcher(listWatcher, b.listWatchMetrics, reflect.TypeOf(expectedType).String(), useAPIServerCache) - reflector := cache.NewReflector(sharding.NewShardedListWatch(b.shard, b.totalShards, instrumentedListWatch), expectedType, store, 0) + reflector := cache.NewReflectorWithOptions(sharding.NewShardedListWatch(b.shard, b.totalShards, instrumentedListWatch), expectedType, store, cache.ReflectorOptions{ResyncPeriod: 0}) go reflector.Run(b.ctx.Done()) } diff --git a/tests/lib/lib_test.go b/tests/lib/lib_test.go index ba96edf00e..25c0cd426a 100644 --- a/tests/lib/lib_test.go +++ b/tests/lib/lib_test.go @@ -79,7 +79,7 @@ func serviceCollector(kubeClient clientset.Interface) *metricsstore.MetricsStore }, } - r := cache.NewReflector(&lw, &v1.Service{}, store, 0) + r := cache.NewReflectorWithOptions(&lw, &v1.Service{}, store, cache.ReflectorOptions{ResyncPeriod: 0}) go r.Run(context.TODO().Done()) From 3aebcf71a9da8df9cff2ecf3ba2c47017e329b81 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Wed, 24 Jul 2024 16:36:46 -0700 Subject: [PATCH 066/154] fix: syntax errors in kube-state-metrics.libsonnet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously customizing kube-prometheus [1] failed with the following error. ❯ ./build.sh example.jsonnet + set -o pipefail + rm -rf manifests + mkdir -p manifests/setup + jsonnet -J vendor -m manifests example.jsonnet + xargs '-I{}' sh -c 'cat {} | gojsontoyaml > {}.yaml' -- '{}' RUNTIME ERROR: vendor/github.com/kubernetes/kube-state-metrics/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet:392:21-22 Expected token OPERATOR but got "{" vendor/kube-prometheus/components/kube-state-metrics.libsonnet:51:19-124 function vendor/kube-prometheus/main.libsonnet:136:21-64 object vendor/kube-prometheus/platforms/platforms.libsonnet:37:22-40 +: example.jsonnet:33:90-109 thunk from <$> :1539:24-25 thunk from > :1539:5-33 function example.jsonnet:33:73-110 $ example.jsonnet:33:1-112 example.jsonnet:33:1-112 During evaluation With this patch, the build succeeds: ❯ bash build.sh example.jsonnet ; echo $? + set -o pipefail + rm -rf manifests + mkdir -p manifests/setup + jsonnet -J vendor -m manifests example.jsonnet + xargs '-I{}' sh -c 'cat {} | gojsontoyaml > {}.yaml' -- '{}' + find manifests -type f '!' -name '*.yaml' -delete + rm -f kustomization 0 [1]: https://github.com/prometheus-operator/kube-prometheus/blob/main/docs/customizing.md --- .../deployment-no-node-pods-service.yaml | 2 +- .../deployment-no-node-pods.yaml | 10 +-- .../kube-state-metrics.libsonnet | 73 ++++++++++--------- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/examples/daemonsetsharding/deployment-no-node-pods-service.yaml b/examples/daemonsetsharding/deployment-no-node-pods-service.yaml index 5f287b7aa1..ddf0892377 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods-service.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods-service.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics-no-node-pods - app.kubernetes.io/version: 2.12.0 + app.kubernetes.io/version: 2.13.0 name: kube-state-metrics-no-node-pods namespace: kube-system spec: diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-no-node-pods.yaml index eac87a53ca..c3b6c00bcf 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods.yaml @@ -3,20 +3,20 @@ kind: Deployment metadata: labels: app.kubernetes.io/component: exporter - app.kubernetes.io/name: kube-state-metrics-no-node-pods + app.kubernetes.io/name: kube-state-metrics-unscheduled-pods-fetching app.kubernetes.io/version: 2.13.0 - name: kube-state-metrics-no-node-pods + name: kube-state-metrics-unscheduled-pods-fetching namespace: kube-system spec: replicas: 1 selector: matchLabels: - app.kubernetes.io/name: kube-state-metrics-no-node-pods + app.kubernetes.io/name: kube-state-metrics-unscheduled-pods-fetching template: metadata: labels: app.kubernetes.io/component: exporter - app.kubernetes.io/name: kube-state-metrics-no-node-pods + app.kubernetes.io/name: kube-state-metrics-unscheduled-pods-fetching app.kubernetes.io/version: 2.13.0 spec: automountServiceAccountToken: true @@ -31,7 +31,7 @@ spec: port: http-metrics initialDelaySeconds: 5 timeoutSeconds: 5 - name: kube-state-metrics-no-node-pods + name: kube-state-metrics-unscheduled-pods-fetching ports: - containerPort: 8080 name: http-metrics diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index 13bef45541..aab7a7e2d9 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -1,4 +1,3 @@ - { local ksm = self, name:: error 'must set namespace', @@ -164,7 +163,7 @@ ], verbs: ['list', 'watch'], }, - ]; + ]; { apiVersion: 'rbac.authorization.k8s.io/v1', @@ -192,11 +191,11 @@ seccompProfile: { type: 'RuntimeDefault' }, }, livenessProbe: { timeoutSeconds: 5, initialDelaySeconds: 5, httpGet: { - port: "http-metrics", + port: 'http-metrics', path: '/livez', } }, readinessProbe: { timeoutSeconds: 5, initialDelaySeconds: 5, httpGet: { - port: "telemetry", + port: 'telemetry', path: '/readyz', } }, }; @@ -344,16 +343,17 @@ clusterRoleBinding: ksm.clusterRoleBinding, }, daemonsetsharding:: { - local shardksmname = ksm.name + "-shard", - daemonsetService: std.mergePatch(ksm.service, - { - metadata: { - name: shardksmname, - labels: {'app.kubernetes.io/name': shardksmname} - }, - spec: {selector: {'app.kubernetes.io/name': shardksmname}}, - } - ), + local shardksmname = ksm.name + '-shard', + daemonsetService: std.mergePatch( + ksm.service, + { + metadata: { + name: shardksmname, + labels: { 'app.kubernetes.io/name': shardksmname }, + }, + spec: { selector: { 'app.kubernetes.io/name': shardksmname } }, + } + ), deployment: // extending the default container from above local c = ksm.deployment.spec.template.spec.containers[0] { @@ -361,7 +361,8 @@ '--resources=certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments', ], }; - std.mergePatch(ksm.deployment, + std.mergePatch( + ksm.deployment, { spec: { template: { @@ -374,6 +375,7 @@ ), deploymentNoNodePods: + local shardksmname = ksm.name + '-unscheduled-pods-fetching'; local c = ksm.deployment.spec.template.spec.containers[0] { args: [ '--resources=pods', @@ -381,23 +383,23 @@ ], name: shardksmname, }; - local shardksmname = ksm.name + "-unscheduled-pods-fetching"; - std.mergePatch(ksm.deployment, + std.mergePatch( + ksm.deployment, { metadata: { name: shardksmname, - labels: {'app.kubernetes.io/name': shardksmname} + labels: { 'app.kubernetes.io/name': shardksmname }, }, spec: { - selector{ - matchLabels: {app.kubernetes.io/name': shardksmname} - } + selector: { + matchLabels: { 'app.kubernetes.io/name': shardksmname }, + }, template: { metadata: { labels: { - app.kubernetes.io/name': shardksmname - } - } + 'app.kubernetes.io/name': shardksmname, + }, + }, spec: { containers: [c], }, @@ -413,18 +415,19 @@ '--track-unscheduled-pods', ], }; - local shardksmname = ksm.name + "-no-node-pods"; - std.mergePatch(ksm.service, + local shardksmname = ksm.name + '-no-node-pods'; + std.mergePatch( + ksm.service, { metadata: { name: shardksmname, - labels: {'app.kubernetes.io/name': shardksmname} + labels: { 'app.kubernetes.io/name': shardksmname }, }, spec: { selector: { - 'app.kubernetes.io/name': shardksmname - } - } + 'app.kubernetes.io/name': shardksmname, + }, + }, } ), daemonset: @@ -439,10 +442,10 @@ ], }; - local c = std.mergePatch(c0, {name: shardksmname}); + local c = std.mergePatch(c0, { name: shardksmname }); - local ksmLabels = std.mergePatch(ksm.commonLabels + ksm.extraRecommendedLabels, {'app.kubernetes.io/name': shardksmname}); - local ksmPodLabels = std.mergePatch(ksm.podLabels, {'app.kubernetes.io/name': shardksmname}); + local ksmLabels = std.mergePatch(ksm.commonLabels + ksm.extraRecommendedLabels, { 'app.kubernetes.io/name': shardksmname }); + local ksmPodLabels = std.mergePatch(ksm.podLabels, { 'app.kubernetes.io/name': shardksmname }); { apiVersion: 'apps/v1', @@ -450,7 +453,7 @@ metadata: { namespace: ksm.namespace, labels: ksmLabels, - name: shardksmname, + name: shardksmname, }, spec: { selector: { matchLabels: ksmPodLabels }, @@ -475,5 +478,3 @@ clusterRoleBinding: ksm.clusterRoleBinding, }, } - - From f44bafd9af8f99ee4bd717009eb05a9a779f53f7 Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Mon, 5 Aug 2024 11:52:04 -0400 Subject: [PATCH 067/154] Fix e2e test failure --- tests/e2e.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e.sh b/tests/e2e.sh index be25eb8060..fe3cf71d37 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -126,7 +126,7 @@ function test_daemonset() { kubectl get deployment -n kube-system kubectl create -f ./examples/daemonsetsharding - kube_state_metrics_up kube-state-metrics-no-node-pods + kube_state_metrics_up kube-state-metrics-unscheduled-pods-fetching kube_state_metrics_up kube-state-metrics kube_state_metrics_up kube-state-metrics-shard kubectl apply -f ./tests/e2e/testdata/pods.yaml @@ -147,11 +147,11 @@ function test_daemonset() { exit 1 fi - kubectl logs deployment/kube-state-metrics-no-node-pods -n kube-system + kubectl logs deployment/kube-state-metrics-unscheduled-pods-fetching -n kube-system sleep 2 kubectl get pods -A --field-selector spec.nodeName="" sleep 2 - pendingpod2="$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-no-node-pods:http-metrics/proxy/metrics" | grep "pendingpod2" | grep -c "kube_pod_info" )" + pendingpod2="$(curl -s "http://localhost:8001/api/v1/namespaces/kube-system/services/kube-state-metrics-unscheduled-pods-fetching:http-metrics/proxy/metrics" | grep "pendingpod2" | grep -c "kube_pod_info" )" if [ "${pendingpod2}" != "${expected_num_pod}" ]; then echo "metric kube_pod_info for pendingpod2 doesn't show up only once, got ${runningpod1} times" exit 1 From aeade6169838b267876f35c9cf83fee5b9fcb2d0 Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Mon, 5 Aug 2024 12:05:17 -0400 Subject: [PATCH 068/154] Update kube-state-metrics.libsonnet --- jsonnet/kube-state-metrics/kube-state-metrics.libsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index aab7a7e2d9..a035cbae48 100644 --- a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet +++ b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet @@ -415,7 +415,7 @@ '--track-unscheduled-pods', ], }; - local shardksmname = ksm.name + '-no-node-pods'; + local shardksmname = ksm.name + '-unscheduled-pods-fetching'; std.mergePatch( ksm.service, { From 720ea8cd89df2f66a1176ffe8fe909f2858f91a2 Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Mon, 5 Aug 2024 12:05:51 -0400 Subject: [PATCH 069/154] Update deployment-no-node-pods-service.yaml --- .../daemonsetsharding/deployment-no-node-pods-service.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/daemonsetsharding/deployment-no-node-pods-service.yaml b/examples/daemonsetsharding/deployment-no-node-pods-service.yaml index ddf0892377..9a83eddcf8 100644 --- a/examples/daemonsetsharding/deployment-no-node-pods-service.yaml +++ b/examples/daemonsetsharding/deployment-no-node-pods-service.yaml @@ -3,9 +3,9 @@ kind: Service metadata: labels: app.kubernetes.io/component: exporter - app.kubernetes.io/name: kube-state-metrics-no-node-pods + app.kubernetes.io/name: kube-state-metrics-unscheduled-pods-fetching app.kubernetes.io/version: 2.13.0 - name: kube-state-metrics-no-node-pods + name: kube-state-metrics-unscheduled-pods-fetching namespace: kube-system spec: clusterIP: None @@ -17,4 +17,4 @@ spec: port: 8081 targetPort: telemetry selector: - app.kubernetes.io/name: kube-state-metrics-no-node-pods + app.kubernetes.io/name: kube-state-metrics-unscheduled-pods-fetching From 311d3f749a0093d4b8d4a8cc499aa2f02927f86b Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Mon, 5 Aug 2024 12:06:22 -0400 Subject: [PATCH 070/154] Rename deployment-no-node-pods-service.yaml to deployment-unscheduled-pods-fetching-service.yaml --- ...ice.yaml => deployment-unscheduled-pods-fetching-service.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/daemonsetsharding/{deployment-no-node-pods-service.yaml => deployment-unscheduled-pods-fetching-service.yaml} (100%) diff --git a/examples/daemonsetsharding/deployment-no-node-pods-service.yaml b/examples/daemonsetsharding/deployment-unscheduled-pods-fetching-service.yaml similarity index 100% rename from examples/daemonsetsharding/deployment-no-node-pods-service.yaml rename to examples/daemonsetsharding/deployment-unscheduled-pods-fetching-service.yaml From cdce0e3278f44f455fcba236a8d8e04f81734bd3 Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Mon, 5 Aug 2024 12:06:35 -0400 Subject: [PATCH 071/154] Rename deployment-no-node-pods.yaml to deployment-unscheduled-pods-fetching.yaml --- ...o-node-pods.yaml => deployment-unscheduled-pods-fetching.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/daemonsetsharding/{deployment-no-node-pods.yaml => deployment-unscheduled-pods-fetching.yaml} (100%) diff --git a/examples/daemonsetsharding/deployment-no-node-pods.yaml b/examples/daemonsetsharding/deployment-unscheduled-pods-fetching.yaml similarity index 100% rename from examples/daemonsetsharding/deployment-no-node-pods.yaml rename to examples/daemonsetsharding/deployment-unscheduled-pods-fetching.yaml From b43702ed1405908879de80c0f81bd42be13243d4 Mon Sep 17 00:00:00 2001 From: CatherineF-dev Date: Mon, 5 Aug 2024 12:17:18 -0400 Subject: [PATCH 072/154] Update e2e.sh --- tests/e2e.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e.sh b/tests/e2e.sh index fe3cf71d37..3856553589 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -122,7 +122,7 @@ function kube_pod_up() { function test_daemonset() { sed -i "s|${KUBE_STATE_METRICS_CURRENT_IMAGE_NAME}:v.*|${KUBE_STATE_METRICS_IMAGE_NAME}:${KUBE_STATE_METRICS_IMAGE_TAG}|g" ./examples/daemonsetsharding/deployment.yaml sed -i "s|${KUBE_STATE_METRICS_CURRENT_IMAGE_NAME}:v.*|${KUBE_STATE_METRICS_IMAGE_NAME}:${KUBE_STATE_METRICS_IMAGE_TAG}|g" ./examples/daemonsetsharding/daemonset.yaml - sed -i "s|${KUBE_STATE_METRICS_CURRENT_IMAGE_NAME}:v.*|${KUBE_STATE_METRICS_IMAGE_NAME}:${KUBE_STATE_METRICS_IMAGE_TAG}|g" ./examples/daemonsetsharding/deployment-no-node-pods.yaml + sed -i "s|${KUBE_STATE_METRICS_CURRENT_IMAGE_NAME}:v.*|${KUBE_STATE_METRICS_IMAGE_NAME}:${KUBE_STATE_METRICS_IMAGE_TAG}|g" ./examples/daemonsetsharding/deployment-unscheduled-pods-fetching.yaml kubectl get deployment -n kube-system kubectl create -f ./examples/daemonsetsharding From a652104decb7d302ec23a047d244fe3a1515a3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 5 Aug 2024 17:49:17 +0200 Subject: [PATCH 073/154] chore: Remove unused dynamicClient --- pkg/util/utils.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 14b108f37e..e10afdcd25 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -24,7 +24,6 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/discovery" - "k8s.io/client-go/dynamic" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" @@ -40,7 +39,6 @@ import ( var config *rest.Config var currentKubeClient clientset.Interface var currentDiscoveryClient *discovery.DiscoveryClient -var currentDynamicClient *dynamic.DynamicClient // CreateKubeClient creates a Kubernetes clientset and a custom resource clientset. func CreateKubeClient(apiserver string, kubeconfig string) (clientset.Interface, error) { @@ -120,22 +118,6 @@ func CreateDiscoveryClient(apiserver string, kubeconfig string) (*discovery.Disc return currentDiscoveryClient, err } -// CreateDynamicClient creates a Kubernetes dynamic client. -func CreateDynamicClient(apiserver string, kubeconfig string) (*dynamic.DynamicClient, error) { - if currentDynamicClient != nil { - return currentDynamicClient, nil - } - var err error - if config == nil { - config, err = clientcmd.BuildConfigFromFlags(apiserver, kubeconfig) - if err != nil { - return nil, err - } - } - currentDynamicClient, err = dynamic.NewForConfig(config) - return currentDynamicClient, err -} - // GVRFromType returns the GroupVersionResource for a given type. func GVRFromType(resourceName string, expectedType interface{}) *schema.GroupVersionResource { if _, ok := expectedType.(*testUnstructuredMock.Foo); ok { From 2548615cd79c7e4a7d6394340016ddcfbc4ade0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 5 Aug 2024 18:28:11 +0200 Subject: [PATCH 074/154] chore: Add unused linter to golangci --- .golangci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yml b/.golangci.yml index edbd40a820..15d5dd160a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -17,6 +17,7 @@ linters: - revive - staticcheck - unconvert + - unused linters-settings: goimports: From ab06f81c004ed3405a749e92c60ee512f107ede4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 5 Aug 2024 19:35:51 +0200 Subject: [PATCH 075/154] chore: Remove further unused --- internal/discovery/discovery_test.go | 21 ++++++++++----------- internal/store/networkpolicy_test.go | 4 ---- pkg/metrics_store/metrics_store_test.go | 11 ----------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/internal/discovery/discovery_test.go b/internal/discovery/discovery_test.go index 39d81aebe2..1466ce2995 100644 --- a/internal/discovery/discovery_test.go +++ b/internal/discovery/discovery_test.go @@ -1,14 +1,14 @@ /* -Copyright 2023 The Kubernetes Authors All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + Copyright 2023 The Kubernetes Authors All rights reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package discovery @@ -26,7 +26,6 @@ func TestGVKMapsResolveGVK(t *testing.T) { desc string gvkmaps *CRDiscoverer gvk schema.GroupVersionKind - got []groupVersionKindPlural want []groupVersionKindPlural } testcases := []testcase{ diff --git a/internal/store/networkpolicy_test.go b/internal/store/networkpolicy_test.go index 8079b9cfcd..ced74c7954 100644 --- a/internal/store/networkpolicy_test.go +++ b/internal/store/networkpolicy_test.go @@ -29,10 +29,6 @@ func TestNetworkPolicyStore(t *testing.T) { startTime := 1501569018 metav1StartTime := metav1.Unix(int64(startTime), 0) - const metadata = ` - # HELP kube_verticalpodautoscaler_labels Kubernetes labels converted to Prometheus labels. - # TYPE kube_verticalpodautoscaler_labels gauge - ` cases := []generateMetricsTestCase{ { Obj: &networkingv1.NetworkPolicy{ diff --git a/pkg/metrics_store/metrics_store_test.go b/pkg/metrics_store/metrics_store_test.go index dbde02b98a..79514960f6 100644 --- a/pkg/metrics_store/metrics_store_test.go +++ b/pkg/metrics_store/metrics_store_test.go @@ -29,17 +29,6 @@ import ( "k8s.io/kube-state-metrics/v2/pkg/metric" ) -// Mock metricFamily instead of importing /pkg/metric to prevent cyclic -// dependency. -type metricFamily struct { - value []byte -} - -// Implement FamilyByteSlicer interface. -func (f *metricFamily) ByteSlice() []byte { - return f.value -} - func TestObjectsSameNameDifferentNamespaces(t *testing.T) { serviceIDs := []string{"a", "b"} From 089ed4551f82b9739dab90d6757e59b7354411e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 8 Aug 2024 18:55:08 +0200 Subject: [PATCH 076/154] chore: Bump e2e kind node to 1.30 --- tests/e2e.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e.sh b/tests/e2e.sh index 3856553589..68928354c7 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -25,7 +25,7 @@ case $(uname -m) in esac NODE_IMAGE_NAME="docker.io/kindest/node" -KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.29.0"} +KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.30.0"} KUBE_STATE_METRICS_LOG_DIR=./log KUBE_STATE_METRICS_CURRENT_IMAGE_NAME="registry.k8s.io/kube-state-metrics/kube-state-metrics" KUBE_STATE_METRICS_IMAGE_NAME="registry.k8s.io/kube-state-metrics/kube-state-metrics-${ARCH}" From 0a86b24b08431c597519e19937b07162247035e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 8 Aug 2024 18:57:22 +0200 Subject: [PATCH 077/154] chore: Memory align structs pkg/metric_generator/generator.go:32:22: 16 bytes saved: struct with 96 pointer bytes could be 80 pkg/metrics_store/metrics_store.go:31:19: 40 bytes saved: struct with 64 pointer bytes could be 24 pkg/options/options.go:42:14: 24 bytes saved: struct of size 384 could be 360 internal/store/builder.go:67:14: 8 bytes saved: struct of size 200 could be 192 internal/store/pod.go:1351:16: 8 bytes saved: struct with 16 pointer bytes could be 8 internal/store/pod.go:1477:20: 8 bytes saved: struct with 16 pointer bytes could be 8 internal/store/testutils.go:32:30: 16 bytes saved: struct with 136 pointer bytes could be 120 pkg/metricshandler/metrics_handler.go:46:21: 8 bytes saved: struct of size 104 could be 96 internal/discovery/types.go:39:19: 32 bytes saved: struct with 88 pointer bytes could be 56 pkg/customresourcestate/config.go:51:15: 16 bytes saved: struct with 112 pointer bytes could be 96 pkg/customresourcestate/config.go:134:16: 8 bytes saved: struct with 88 pointer bytes could be 80 pkg/customresourcestate/config.go:150:13: 8 bytes saved: struct with 40 pointer bytes could be 32 pkg/customresourcestate/config_metrics_types.go:29:18: 8 bytes saved: struct with 64 pointer bytes could be 56 pkg/customresourcestate/config_metrics_types.go:42:17: 8 bytes saved: struct with 40 pointer bytes could be 32 pkg/customresourcestate/registry_factory.go:125:21: 8 bytes saved: struct with 40 pointer bytes could be 32 pkg/customresourcestate/registry_factory.go:212:20: 16 bytes saved: struct with 88 pointer bytes could be 72 pkg/customresourcestate/registry_factory.go:377:23: 8 bytes saved: struct with 104 pointer bytes could be 96 pkg/customresourcestate/registry_factory.go:497:21: 8 bytes saved: struct with 64 pointer bytes could be 56 pkg/customresourcestate/registry_factory.go:549:13: 8 bytes saved: struct with 24 pointer bytes could be 16 --- internal/discovery/types.go | 12 ++-- internal/store/builder.go | 18 ++--- internal/store/pod.go | 20 +++--- internal/store/testutils.go | 4 +- pkg/customresourcestate/config.go | 25 +++---- .../config_metrics_types.go | 8 +-- pkg/customresourcestate/registry_factory.go | 12 ++-- pkg/metric_generator/generator.go | 4 +- pkg/metrics_store/metrics_store.go | 11 +-- pkg/metricshandler/metrics_handler.go | 16 ++--- pkg/options/options.go | 70 ++++++++++--------- 11 files changed, 102 insertions(+), 98 deletions(-) diff --git a/internal/discovery/types.go b/internal/discovery/types.go index 7de4a6ca4a..5b95778a8e 100644 --- a/internal/discovery/types.go +++ b/internal/discovery/types.go @@ -37,18 +37,18 @@ type kindPlural struct { // CRDiscoverer provides a cache of the collected GVKs, along with helper utilities. type CRDiscoverer struct { - // m is a mutex to protect the cache. - m sync.RWMutex - // Map is a cache of the collected GVKs. - Map map[string]map[string][]kindPlural - // ShouldUpdate is a flag that indicates whether the cache was updated. - WasUpdated bool // CRDsAddEventsCounter tracks the number of times that the CRD informer triggered the "add" event. CRDsAddEventsCounter prometheus.Counter // CRDsDeleteEventsCounter tracks the number of times that the CRD informer triggered the "remove" event. CRDsDeleteEventsCounter prometheus.Counter // CRDsCacheCountGauge tracks the net amount of CRDs affecting the cache at this point. CRDsCacheCountGauge prometheus.Gauge + // Map is a cache of the collected GVKs. + Map map[string]map[string][]kindPlural + // m is a mutex to protect the cache. + m sync.RWMutex + // ShouldUpdate is a flag that indicates whether the cache was updated. + WasUpdated bool } // SafeRead executes the given function while holding a read lock. diff --git a/internal/store/builder.go b/internal/store/builder.go index db4e06baa9..f7941794e4 100644 --- a/internal/store/builder.go +++ b/internal/store/builder.go @@ -65,24 +65,24 @@ var _ ksmtypes.BuilderInterface = &Builder{} // Builder helps to build store. It follows the builder pattern // (https://en.wikipedia.org/wiki/Builder_pattern). type Builder struct { - kubeClient clientset.Interface - customResourceClients map[string]interface{} - namespaces options.NamespaceList - // namespaceFilter is inside fieldSelectorFilter - fieldSelectorFilter string + kubeClient clientset.Interface ctx context.Context - enabledResources []string familyGeneratorFilter generator.FamilyGeneratorFilter + customResourceClients map[string]interface{} listWatchMetrics *watch.ListWatchMetrics shardingMetrics *sharding.Metrics - shard int32 - totalShards int buildStoresFunc ksmtypes.BuildStoresFunc buildCustomResourceStoresFunc ksmtypes.BuildCustomResourceStoresFunc allowAnnotationsList map[string][]string allowLabelsList map[string][]string - useAPIServerCache bool utilOptions *options.Options + // namespaceFilter is inside fieldSelectorFilter + fieldSelectorFilter string + namespaces options.NamespaceList + enabledResources []string + totalShards int + shard int32 + useAPIServerCache bool } // NewBuilder returns a new builder. diff --git a/internal/store/pod.go b/internal/store/pod.go index 82da1a43b3..8c39017283 100644 --- a/internal/store/pod.go +++ b/internal/store/pod.go @@ -1349,14 +1349,14 @@ func createPodStatusPhaseFamilyGenerator() generator.FamilyGenerator { } phases := []struct { - v bool n string + v bool }{ - {phase == v1.PodPending, string(v1.PodPending)}, - {phase == v1.PodSucceeded, string(v1.PodSucceeded)}, - {phase == v1.PodFailed, string(v1.PodFailed)}, - {phase == v1.PodUnknown, string(v1.PodUnknown)}, - {phase == v1.PodRunning, string(v1.PodRunning)}, + {string(v1.PodPending), phase == v1.PodPending}, + {string(v1.PodSucceeded), phase == v1.PodSucceeded}, + {string(v1.PodFailed), phase == v1.PodFailed}, + {string(v1.PodUnknown), phase == v1.PodUnknown}, + {string(v1.PodRunning), phase == v1.PodRunning}, } ms := make([]*metric.Metric, len(phases)) @@ -1475,12 +1475,12 @@ func createPodStatusQosClassFamilyGenerator() generator.FamilyGenerator { } qosClasses := []struct { - v bool n string + v bool }{ - {class == v1.PodQOSBestEffort, string(v1.PodQOSBestEffort)}, - {class == v1.PodQOSBurstable, string(v1.PodQOSBurstable)}, - {class == v1.PodQOSGuaranteed, string(v1.PodQOSGuaranteed)}, + {string(v1.PodQOSBestEffort), class == v1.PodQOSBestEffort}, + {string(v1.PodQOSBurstable), class == v1.PodQOSBurstable}, + {string(v1.PodQOSGuaranteed), class == v1.PodQOSGuaranteed}, } ms := make([]*metric.Metric, len(qosClasses)) diff --git a/internal/store/testutils.go b/internal/store/testutils.go index 8de6c52ae2..2c52838fff 100644 --- a/internal/store/testutils.go +++ b/internal/store/testutils.go @@ -31,12 +31,12 @@ import ( type generateMetricsTestCase struct { Obj interface{} + Func func(interface{}) []metric.FamilyInterface + Want string MetricNames []string AllowAnnotationsList []string AllowLabelsList []string - Want string Headers []string - Func func(interface{}) []metric.FamilyInterface } func (testCase *generateMetricsTestCase) run() error { diff --git a/pkg/customresourcestate/config.go b/pkg/customresourcestate/config.go index 873591372f..f9beb2083e 100644 --- a/pkg/customresourcestate/config.go +++ b/pkg/customresourcestate/config.go @@ -49,6 +49,10 @@ type MetricsSpec struct { // Resource configures a custom resource for metric generation. type Resource struct { + + // Labels are added to all metrics. If the same key is used in a metric, the value from the metric will overwrite the value here. + Labels `yaml:",inline" json:",inline"` + // MetricNamePrefix defines a prefix for all metrics of the resource. // If set to "", no prefix will be added. // Example: If set to "foo", MetricNamePrefix will be "foo_". @@ -57,16 +61,13 @@ type Resource struct { // GroupVersionKind of the custom resource to be monitored. GroupVersionKind GroupVersionKind `yaml:"groupVersionKind" json:"groupVersionKind"` - // Labels are added to all metrics. If the same key is used in a metric, the value from the metric will overwrite the value here. - Labels `yaml:",inline" json:",inline"` + // ResourcePlural sets the plural name of the resource. Defaults to the plural version of the Kind according to flect.Pluralize. + ResourcePlural string `yaml:"resourcePlural" json:"resourcePlural"` // Metrics are the custom resource fields to be collected. Metrics []Generator `yaml:"metrics" json:"metrics"` // ErrorLogV defines the verbosity threshold for errors logged for this resource. ErrorLogV klog.Level `yaml:"errorLogV" json:"errorLogV"` - - // ResourcePlural sets the plural name of the resource. Defaults to the plural version of the Kind according to flect.Pluralize. - ResourcePlural string `yaml:"resourcePlural" json:"resourcePlural"` } // GetMetricNamePrefix returns the prefix to use for metrics. @@ -132,15 +133,15 @@ func (l Labels) Merge(other Labels) Labels { // Generator describes a unique metric name. type Generator struct { - // Name of the metric. Subject to prefixing based on the configuration of the Resource. - Name string `yaml:"name" json:"name"` - // Help text for the metric. - Help string `yaml:"help" json:"help"` // Each targets a value or values from the resource. Each Metric `yaml:"each" json:"each"` // Labels are added to all metrics. Labels from Each will overwrite these if using the same key. Labels `yaml:",inline" json:",inline"` // json will inline because it is already tagged + // Name of the metric. Subject to prefixing based on the configuration of the Resource. + Name string `yaml:"name" json:"name"` + // Help text for the metric. + Help string `yaml:"help" json:"help"` // ErrorLogV defines the verbosity threshold for errors logged for this metric. Must be non-zero to override the resource setting. ErrorLogV klog.Level `yaml:"errorLogV" json:"errorLogV"` } @@ -148,9 +149,6 @@ type Generator struct { // Metric defines a metric to expose. // +union type Metric struct { - // Type defines the type of the metric. - // +unionDiscriminator - Type metric.Type `yaml:"type" json:"type"` // Gauge defines a gauge metric. // +optional @@ -161,6 +159,9 @@ type Metric struct { // Info defines an info metric. // +optional Info *MetricInfo `yaml:"info" json:"info"` + // Type defines the type of the metric. + // +unionDiscriminator + Type metric.Type `yaml:"type" json:"type"` } // ConfigDecoder is for use with FromConfig. diff --git a/pkg/customresourcestate/config_metrics_types.go b/pkg/customresourcestate/config_metrics_types.go index 25d63bfb69..5b06e46421 100644 --- a/pkg/customresourcestate/config_metrics_types.go +++ b/pkg/customresourcestate/config_metrics_types.go @@ -27,12 +27,12 @@ type MetricMeta struct { // MetricGauge targets a Path that may be a single value, array, or object. Arrays and objects will generate a metric per element. // Ref: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#gauge type MetricGauge struct { - MetricMeta `yaml:",inline" json:",inline"` + // LabelFromKey adds a label with the given name if Path is an object. The label value will be the object key. + LabelFromKey string `yaml:"labelFromKey" json:"labelFromKey"` + MetricMeta `yaml:",inline" json:",inline"` // ValueFrom is the path to a numeric field under Path that will be the metric value. ValueFrom []string `yaml:"valueFrom" json:"valueFrom"` - // LabelFromKey adds a label with the given name if Path is an object. The label value will be the object key. - LabelFromKey string `yaml:"labelFromKey" json:"labelFromKey"` // NilIsZero indicates that if a value is nil it will be treated as zero value. NilIsZero bool `yaml:"nilIsZero" json:"nilIsZero"` } @@ -40,9 +40,9 @@ type MetricGauge struct { // MetricInfo is a metric which is used to expose textual information. // Ref: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#info type MetricInfo struct { - MetricMeta `yaml:",inline" json:",inline"` // LabelFromKey adds a label with the given name if Path is an object. The label value will be the object key. LabelFromKey string `yaml:"labelFromKey" json:"labelFromKey"` + MetricMeta `yaml:",inline" json:",inline"` } // MetricStateSet is a metric which represent a series of related boolean values, also called a bitset. diff --git a/pkg/customresourcestate/registry_factory.go b/pkg/customresourcestate/registry_factory.go index c59f5aeabe..e4413d4dc2 100644 --- a/pkg/customresourcestate/registry_factory.go +++ b/pkg/customresourcestate/registry_factory.go @@ -124,8 +124,8 @@ type compiledEach compiledMetric type compiledCommon struct { labelFromPath map[string]valuePath - path valuePath t metric.Type + path valuePath } func (c compiledCommon) Path() valuePath { @@ -211,9 +211,9 @@ func newCompiledMetric(m Metric) (compiledMetric, error) { type compiledGauge struct { compiledCommon + labelFromKey string ValueFrom valuePath NilIsZero bool - labelFromKey string } func (c *compiledGauge) Values(v interface{}) (result []eachValue, errs []error) { @@ -376,9 +376,9 @@ func (c *compiledInfo) values(v interface{}) (result []eachValue, err []error) { type compiledStateSet struct { compiledCommon + LabelName string ValueFrom valuePath List []string - LabelName string } func (c *compiledStateSet) Values(v interface{}) (result []eachValue, errs []error) { @@ -495,11 +495,11 @@ func (e eachValue) ToMetric() *metric.Metric { } type compiledFamily struct { - Name string - Help string Each compiledEach Labels map[string]string LabelFromPath map[string]valuePath + Name string + Help string ErrorLogV klog.Level } @@ -547,8 +547,8 @@ func addPathLabels(obj interface{}, labels map[string]valuePath, result map[stri } type pathOp struct { - part string op func(interface{}) interface{} + part string } type valuePath []pathOp diff --git a/pkg/metric_generator/generator.go b/pkg/metric_generator/generator.go index 2a2e30221f..5601ea5252 100644 --- a/pkg/metric_generator/generator.go +++ b/pkg/metric_generator/generator.go @@ -30,13 +30,13 @@ import ( // DeprecatedVersion is defined only if the metric for which this options applies is, // in fact, deprecated. type FamilyGenerator struct { + GenerateFunc func(obj interface{}) *metric.Family Name string Help string Type metric.Type - OptIn bool DeprecatedVersion string StabilityLevel basemetrics.StabilityLevel - GenerateFunc func(obj interface{}) *metric.Family + OptIn bool } // NewFamilyGeneratorWithStability creates new FamilyGenerator instances with metric diff --git a/pkg/metrics_store/metrics_store.go b/pkg/metrics_store/metrics_store.go index 25b4bb4950..0339101b5b 100644 --- a/pkg/metrics_store/metrics_store.go +++ b/pkg/metrics_store/metrics_store.go @@ -29,21 +29,22 @@ import ( // interface. Instead of storing entire Kubernetes objects, it stores metrics // generated based on those objects. type MetricsStore struct { - // Protects metrics - mutex sync.RWMutex // metrics is a map indexed by Kubernetes object id, containing a slice of // metric families, containing a slice of metrics. We need to keep metrics // grouped by metric families in order to zip families with their help text in // MetricsStore.WriteAll(). metrics map[types.UID][][]byte + + // generateMetricsFunc generates metrics based on a given Kubernetes object + // and returns them grouped by metric family. + generateMetricsFunc func(interface{}) []metric.FamilyInterface // headers contains the header (TYPE and HELP) of each metric family. It is // later on zipped with with their corresponding metric families in // MetricStore.WriteAll(). headers []string - // generateMetricsFunc generates metrics based on a given Kubernetes object - // and returns them grouped by metric family. - generateMetricsFunc func(interface{}) []metric.FamilyInterface + // Protects metrics + mutex sync.RWMutex } // NewMetricsStore returns a new MetricsStore diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index 62543785b0..e944033c12 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -44,18 +44,18 @@ import ( // MetricsHandler is a http.Handler that exposes the main kube-state-metrics // /metrics endpoint. It allows concurrent reconfiguration at runtime. type MetricsHandler struct { - opts *options.Options - kubeClient kubernetes.Interface - storeBuilder ksmtypes.BuilderInterface - enableGZIPEncoding bool + kubeClient kubernetes.Interface + storeBuilder ksmtypes.BuilderInterface + opts *options.Options cancel func() // mtx protects metricsWriters, curShard, and curTotalShards - mtx *sync.RWMutex - metricsWriters metricsstore.MetricsWriterList - curShard int32 - curTotalShards int + mtx *sync.RWMutex + metricsWriters metricsstore.MetricsWriterList + curTotalShards int + curShard int32 + enableGZIPEncoding bool } // New creates and returns a new MetricsHandler with the given options. diff --git a/pkg/options/options.go b/pkg/options/options.go index d10a12cce2..2b601bb439 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -40,43 +40,45 @@ var ( // Options are the configurable parameters for kube-state-metrics. type Options struct { - AnnotationsAllowList LabelsAllowList `yaml:"annotations_allow_list"` - Apiserver string `yaml:"apiserver"` - AutoGoMemlimit bool `yaml:"auto-gomemlimit"` - AutoGoMemlimitRatio float64 `yaml:"auto-gomemlimit-ratio"` - CustomResourceConfig string `yaml:"custom_resource_config"` - CustomResourceConfigFile string `yaml:"custom_resource_config_file"` - CustomResourcesOnly bool `yaml:"custom_resources_only"` - EnableGZIPEncoding bool `yaml:"enable_gzip_encoding"` - Help bool `yaml:"help"` - Host string `yaml:"host"` - Kubeconfig string `yaml:"kubeconfig"` - LabelsAllowList LabelsAllowList `yaml:"labels_allow_list"` - MetricAllowlist MetricSet `yaml:"metric_allowlist"` - MetricDenylist MetricSet `yaml:"metric_denylist"` - MetricOptInList MetricSet `yaml:"metric_opt_in_list"` - Namespace string `yaml:"namespace"` - Namespaces NamespaceList `yaml:"namespaces"` - NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"` - Node NodeType `yaml:"node"` - TrackUnscheduledPods bool `yaml:"track_unscheduled_pods"` - Pod string `yaml:"pod"` - Port int `yaml:"port"` - Resources ResourceSet `yaml:"resources"` - Shard int32 `yaml:"shard"` - TLSConfig string `yaml:"tls_config"` - TelemetryHost string `yaml:"telemetry_host"` - TelemetryPort int `yaml:"telemetry_port"` - TotalShards int `yaml:"total_shards"` - UseAPIServerCache bool `yaml:"use_api_server_cache"` - ServerReadTimeout time.Duration `yaml:"server_read_timeout"` - ServerWriteTimeout time.Duration `yaml:"server_write_timeout"` - ServerIdleTimeout time.Duration `yaml:"server_idle_timeout"` - ServerReadHeaderTimeout time.Duration `yaml:"server_read_header_timeout"` + AnnotationsAllowList LabelsAllowList `yaml:"annotations_allow_list"` + LabelsAllowList LabelsAllowList `yaml:"labels_allow_list"` + MetricAllowlist MetricSet `yaml:"metric_allowlist"` + MetricDenylist MetricSet `yaml:"metric_denylist"` + MetricOptInList MetricSet `yaml:"metric_opt_in_list"` + Resources ResourceSet `yaml:"resources"` + + cmd *cobra.Command + Apiserver string `yaml:"apiserver"` + CustomResourceConfig string `yaml:"custom_resource_config"` + CustomResourceConfigFile string `yaml:"custom_resource_config_file"` + Host string `yaml:"host"` + Kubeconfig string `yaml:"kubeconfig"` + Namespace string `yaml:"namespace"` + Node NodeType `yaml:"node"` + Pod string `yaml:"pod"` + TLSConfig string `yaml:"tls_config"` + TelemetryHost string `yaml:"telemetry_host"` Config string - cmd *cobra.Command + Namespaces NamespaceList `yaml:"namespaces"` + NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"` + AutoGoMemlimitRatio float64 `yaml:"auto-gomemlimit-ratio"` + Port int `yaml:"port"` + TelemetryPort int `yaml:"telemetry_port"` + TotalShards int `yaml:"total_shards"` + ServerReadTimeout time.Duration `yaml:"server_read_timeout"` + ServerWriteTimeout time.Duration `yaml:"server_write_timeout"` + ServerIdleTimeout time.Duration `yaml:"server_idle_timeout"` + ServerReadHeaderTimeout time.Duration `yaml:"server_read_header_timeout"` + + Shard int32 `yaml:"shard"` + AutoGoMemlimit bool `yaml:"auto-gomemlimit"` + CustomResourcesOnly bool `yaml:"custom_resources_only"` + EnableGZIPEncoding bool `yaml:"enable_gzip_encoding"` + Help bool `yaml:"help"` + TrackUnscheduledPods bool `yaml:"track_unscheduled_pods"` + UseAPIServerCache bool `yaml:"use_api_server_cache"` } // GetConfigFile is the getter for --config value. From 894862eb6a4cb4c725ebc64062430ab5fc4dfc4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Aug 2024 15:52:12 +0000 Subject: [PATCH 078/154] build(deps): Bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.19.1 to 1.20.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/v1.20.0/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.20.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 7 ++++--- go.sum | 16 ++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index f51bc6d30a..6ba57615d5 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gobuffalo/flect v1.0.2 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 - github.com/prometheus/client_golang v1.19.1 + github.com/prometheus/client_golang v1.20.0 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.55.0 github.com/prometheus/exporter-toolkit v0.11.0 @@ -32,7 +32,7 @@ require ( require ( github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cilium/ebpf v0.9.1 // indirect github.com/containerd/cgroups/v3 v3.0.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect @@ -58,6 +58,7 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.17.9 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -85,7 +86,7 @@ require ( golang.org/x/net v0.26.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/term v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/go.sum b/go.sum index d22a722d59..ca305a9620 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cilium/ebpf v0.9.1 h1:64sn2K3UKw8NbP/blsixRpF3nXuyhz/VjRlRzvlBRu4= github.com/cilium/ebpf v0.9.1/go.mod h1:+OhNOIXx/Fnu1IE8bJz2dzOA+VSfyTfdNUVdlQnxUFY= github.com/containerd/cgroups/v3 v3.0.1 h1:4hfGvu8rfGIwVIDd+nLzn/B9ZXx4BcCjzt5ToenJRaE= @@ -78,6 +78,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -85,6 +87,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -117,8 +121,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_golang v1.20.0 h1:jBzTZ7B099Rg24tny+qngoynol8LtVYlA2bqx3vEloI= +github.com/prometheus/client_golang v1.20.0/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= @@ -196,8 +200,8 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From dec7a1b93e0066d5d3ec00e992b6165d62723f08 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Fri, 16 Aug 2024 09:43:44 -0700 Subject: [PATCH 079/154] fix(discovery): configure sharding every time MetricsHandler.Run runs Signed-off-by: Walther Lee --- pkg/metricshandler/metrics_handler.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index 62543785b0..85f030bab5 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -132,14 +132,6 @@ func (m *MetricsHandler) Run(ctx context.Context) error { return } - m.mtx.RLock() - shardingUnchanged := m.curShard == shard && m.curTotalShards == totalShards - m.mtx.RUnlock() - - if shardingUnchanged { - return - } - m.ConfigureSharding(ctx, shard, totalShards) }, UpdateFunc: func(oldo, curo interface{}) { From 8359c102fa309c9c278fa22dcc61f5ffad3e9013 Mon Sep 17 00:00:00 2001 From: Daividao Date: Sat, 17 Aug 2024 16:21:24 -0700 Subject: [PATCH 080/154] Fix outdated RegistryFactory.MetricFamilyGenerators comments --- pkg/customresource/registry_factory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/customresource/registry_factory.go b/pkg/customresource/registry_factory.go index a14d87dc1b..2edc0fe1eb 100644 --- a/pkg/customresource/registry_factory.go +++ b/pkg/customresource/registry_factory.go @@ -50,7 +50,7 @@ type RegistryFactory interface { // // Example: // - // func (f *FooFactory) MetricFamilyGenerators(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator { + // func (f *FooFactory) MetricFamilyGenerators() []generator.FamilyGenerator { // return []generator.FamilyGenerator{ // *generator.NewFamilyGeneratorWithStability( // "kube_foo_spec_replicas", From 1408e45721d39e72150e1c5543b11db007b7d5c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:55:13 +0000 Subject: [PATCH 081/154] build(deps): Bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.20.0 to 1.20.1. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/v1.20.1/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.20.0...v1.20.1) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6ba57615d5..18770c1c92 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gobuffalo/flect v1.0.2 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 - github.com/prometheus/client_golang v1.20.0 + github.com/prometheus/client_golang v1.20.1 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.55.0 github.com/prometheus/exporter-toolkit v0.11.0 diff --git a/go.sum b/go.sum index ca305a9620..c2e48d2022 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.0 h1:jBzTZ7B099Rg24tny+qngoynol8LtVYlA2bqx3vEloI= -github.com/prometheus/client_golang v1.20.0/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8= +github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= From 1e8fd2c1073837d7048be92ad1bc11700b67c5f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 17:56:28 +0000 Subject: [PATCH 082/154] build(deps): Bump github.com/jsonnet-bundler/jsonnet-bundler in /tools Bumps [github.com/jsonnet-bundler/jsonnet-bundler](https://github.com/jsonnet-bundler/jsonnet-bundler) from 0.5.1 to 0.6.0. - [Release notes](https://github.com/jsonnet-bundler/jsonnet-bundler/releases) - [Changelog](https://github.com/jsonnet-bundler/jsonnet-bundler/blob/master/CHANGELOG.md) - [Commits](https://github.com/jsonnet-bundler/jsonnet-bundler/compare/v0.5.1...v0.6.0) --- updated-dependencies: - dependency-name: github.com/jsonnet-bundler/jsonnet-bundler dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- tools/go.mod | 3 ++- tools/go.sum | 12 ++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/go.mod b/tools/go.mod index ce3ed7dd37..8f25270889 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -7,7 +7,7 @@ require ( github.com/campoy/embedmd v1.0.0 github.com/google/go-jsonnet v0.20.0 github.com/hairyhenderson/gomplate/v3 v3.11.8 - github.com/jsonnet-bundler/jsonnet-bundler v0.5.1 + github.com/jsonnet-bundler/jsonnet-bundler v0.6.0 golang.org/x/perf v0.0.0-20240604174448-3b48cf0e0164 ) @@ -51,6 +51,7 @@ require ( github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/docker/libkv v0.2.2-0.20180912205406-458977154600 // indirect github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad // indirect + github.com/elliotchance/orderedmap/v2 v2.2.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.13.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect diff --git a/tools/go.sum b/tools/go.sum index bb82af7f3b..69bf42344a 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -273,6 +273,8 @@ github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJ github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/elliotchance/orderedmap/v2 v2.2.0 h1:7/2iwO98kYT4XkOjA9mBEIwvi4KpGB4cyHeOFOnj4Vk= +github.com/elliotchance/orderedmap/v2 v2.2.0/go.mod h1:85lZyVbpGaGvHvnKa7Qhx7zncAdBIBq6u56Hb1PRU5Q= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= @@ -634,8 +636,8 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFF github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jsonnet-bundler/jsonnet-bundler v0.5.1 h1:eUd6EA1Qzz73Q4NLNLOrNkMb96+6NTTERbX9lqaxVwk= -github.com/jsonnet-bundler/jsonnet-bundler v0.5.1/go.mod h1:Qrdw/7mOFS2SKCOALKFfEH8gdvXJi8XZjw9g5ilpf4I= +github.com/jsonnet-bundler/jsonnet-bundler v0.6.0 h1:DBnynmjyWBVQ9gUBmTh49x3Dw5/u4CvGO3k2k1CsYNo= +github.com/jsonnet-bundler/jsonnet-bundler v0.6.0/go.mod h1:5esRxD59TyScj6qxT3o7GH0sryBKvVmx2zaEYDXtQkg= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -654,7 +656,6 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -752,7 +753,6 @@ github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -776,8 +776,6 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -835,7 +833,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= @@ -1152,7 +1149,6 @@ golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From 4d82424e9ea5907da977ee1ccadd818479e101d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 09:25:58 +0000 Subject: [PATCH 083/154] build(deps): Bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.20.1 to 1.20.2. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.20.1...v1.20.2) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 18770c1c92..f07d3208ae 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gobuffalo/flect v1.0.2 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 - github.com/prometheus/client_golang v1.20.1 + github.com/prometheus/client_golang v1.20.2 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.55.0 github.com/prometheus/exporter-toolkit v0.11.0 diff --git a/go.sum b/go.sum index c2e48d2022..7e8d12cb1d 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8= -github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= +github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= From 082aba26c0d7aed9f4ba45d1821196cf506cc139 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Tue, 27 Aug 2024 14:14:07 -0700 Subject: [PATCH 084/154] update discovery to reconfigure sharding Signed-off-by: Walther Lee --- internal/discovery/discovery.go | 22 ++-------------------- pkg/app/server.go | 14 ++++++-------- pkg/metricshandler/metrics_handler.go | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index bd764ab701..ab778113b3 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -203,10 +203,6 @@ func (r *CRDiscoverer) PollForCacheUpdates( ) { // The interval at which we will check the cache for updates. t := time.NewTicker(Interval) - // Track previous context to allow refreshing cache. - olderContext, olderCancel := context.WithCancel(ctx) - // Prevent context leak (kill the last metric handler instance). - defer olderCancel() generateMetrics := func() { // Get families for discovered factories. customFactories, err := factoryGenerator() @@ -239,21 +235,8 @@ func (r *CRDiscoverer) PollForCacheUpdates( r.SafeWrite(func() { r.WasUpdated = false }) - // Run the metrics handler with updated configs. - olderContext, olderCancel = context.WithCancel(ctx) - go func() { - // Blocks indefinitely until the unbuffered context is cancelled to serve metrics for that duration. - err = m.Run(olderContext) - if err != nil { - // Check if context was cancelled. - select { - case <-olderContext.Done(): - // Context cancelled, don't really need to log this though. - default: - klog.ErrorS(err, "failed to run metrics handler") - } - } - }() + // Update metric handler with the new configs. + m.ReconfigureSharding(ctx) } go func() { for range t.C { @@ -269,7 +252,6 @@ func (r *CRDiscoverer) PollForCacheUpdates( shouldGenerateMetrics = r.WasUpdated }) if shouldGenerateMetrics { - olderCancel() generateMetrics() klog.InfoS("discovery finished, cache updated") } diff --git a/pkg/app/server.go b/pkg/app/server.go index 98bb11df01..4d01a0e01d 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -297,14 +297,12 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { opts.EnableGZIPEncoding, ) // Run MetricsHandler - if config == nil { - ctxMetricsHandler, cancel := context.WithCancel(ctx) - g.Add(func() error { - return m.Run(ctxMetricsHandler) - }, func(error) { - cancel() - }) - } + ctxMetricsHandler, cancel := context.WithCancel(ctx) + g.Add(func() error { + return m.Run(ctxMetricsHandler) + }, func(error) { + cancel() + }) tlsConfig := opts.TLSConfig diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index 85f030bab5..6ae02b7a47 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -69,7 +69,16 @@ func New(opts *options.Options, kubeClient kubernetes.Interface, storeBuilder ks } } -// ConfigureSharding (re-)configures sharding. Re-configuration can be done +// ReconfigureSharding reconfigures sharding with the current shard and totalShards, and +// it's a no-op if both values are 0. +func (m *MetricsHandler) ReconfigureSharding(ctx context.Context) { + if m.curShard == 0 && m.curTotalShards == 0 { + return + } + m.ConfigureSharding(ctx, m.curShard, m.curTotalShards) +} + +// ConfigureSharding configures sharding. Configuration can be used mutlitple times and // concurrently. func (m *MetricsHandler) ConfigureSharding(ctx context.Context, shard int32, totalShards int) { m.mtx.Lock() @@ -132,6 +141,14 @@ func (m *MetricsHandler) Run(ctx context.Context) error { return } + m.mtx.RLock() + shardingUnchanged := m.curShard == shard && m.curTotalShards == totalShards + m.mtx.RUnlock() + + if shardingUnchanged { + return + } + m.ConfigureSharding(ctx, shard, totalShards) }, UpdateFunc: func(oldo, curo interface{}) { From 20589ac310a2efec015e0f844449f16640aff5cd Mon Sep 17 00:00:00 2001 From: Richa Banker Date: Fri, 23 Aug 2024 15:14:55 -0700 Subject: [PATCH 085/154] Set metric even when there are no job.Status.Conditions present --- internal/store/job.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/store/job.go b/internal/store/job.go index 6e0e97b218..8dd53b0a19 100644 --- a/internal/store/job.go +++ b/internal/store/job.go @@ -219,10 +219,10 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } } + reasonKnown := false for _, c := range j.Status.Conditions { condition := c if condition.Type == v1batch.JobFailed { - reasonKnown := false for _, reason := range jobFailureReasons { reasonKnown = reasonKnown || failureReason(&condition, reason) @@ -233,16 +233,16 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat Value: boolFloat64(failureReason(&condition, reason)), }) } - // for unknown reasons - if !reasonKnown { - ms = append(ms, &metric.Metric{ - LabelKeys: []string{"reason"}, - LabelValues: []string{""}, - Value: float64(j.Status.Failed), - }) - } } } + // for unknown reasons + if !reasonKnown { + ms = append(ms, &metric.Metric{ + LabelKeys: []string{"reason"}, + LabelValues: []string{""}, + Value: float64(j.Status.Failed), + }) + } return &metric.Family{ Metrics: ms, From 643739d04a03d5263868194efc5d3f9664e158ee Mon Sep 17 00:00:00 2001 From: Richa Banker Date: Tue, 27 Aug 2024 20:11:39 -0700 Subject: [PATCH 086/154] Add unit test --- internal/store/job_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/internal/store/job_test.go b/internal/store/job_test.go index b45ac1ab15..b808c321b5 100644 --- a/internal/store/job_test.go +++ b/internal/store/job_test.go @@ -208,6 +208,28 @@ func TestJobStore(t *testing.T) { kube_job_status_failed{job_name="FailedJob1",namespace="ns1",reason="Evicted"} 0 kube_job_status_start_time{job_name="FailedJob1",namespace="ns1"} 1.495807207e+09 kube_job_status_succeeded{job_name="FailedJob1",namespace="ns1"} 0 +`, + }, + { + Obj: &v1batch.Job{ + ObjectMeta: metav1.ObjectMeta{ + Name: "FailedJobWithNoConditions", + Namespace: "ns1", + }, + Status: v1batch.JobStatus{ + Failed: 1, + }, + Spec: v1batch.JobSpec{ + ActiveDeadlineSeconds: &ActiveDeadlineSeconds900, + }, + }, + Want: metadata + ` + kube_job_owner{job_name="FailedJobWithNoConditions",namespace="ns1",owner_is_controller="",owner_kind="",owner_name=""} 1 + kube_job_info{job_name="FailedJobWithNoConditions",namespace="ns1"} 1 + kube_job_spec_active_deadline_seconds{job_name="FailedJobWithNoConditions",namespace="ns1"} 900 + kube_job_status_active{job_name="FailedJobWithNoConditions",namespace="ns1"} 0 + kube_job_status_failed{job_name="FailedJobWithNoConditions",namespace="ns1",reason=""} 1 + kube_job_status_succeeded{job_name="FailedJobWithNoConditions",namespace="ns1"} 0 `, }, { From 218f051024dc74395faba29c1e24a8c2e88ceee2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:54:52 +0000 Subject: [PATCH 087/154] build(deps): Bump github.com/prometheus/common from 0.55.0 to 0.57.0 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.55.0 to 0.57.0. - [Release notes](https://github.com/prometheus/common/releases) - [Changelog](https://github.com/prometheus/common/blob/main/RELEASE.md) - [Commits](https://github.com/prometheus/common/compare/v0.55.0...v0.57.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index f07d3208ae..206ce2a1b8 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.20.2 github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common v0.55.0 + github.com/prometheus/common v0.57.0 github.com/prometheus/exporter-toolkit v0.11.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.1 @@ -81,13 +81,13 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.24.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.26.0 // indirect + golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect - golang.org/x/term v0.21.0 // indirect + golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/go.sum b/go.sum index 7e8d12cb1d..90384ce168 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjs github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/common v0.57.0 h1:Ro/rKjwdq9mZn1K5QPctzh+MA4Lp0BuYk5ZZEVhoNcY= +github.com/prometheus/common v0.57.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= @@ -177,8 +177,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -187,8 +187,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -202,8 +202,8 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= From 805b70a086997ea75d720a2b2e22b958f3344ccc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 20:26:09 +0000 Subject: [PATCH 088/154] build(deps): Bump github.com/prometheus/exporter-toolkit Bumps [github.com/prometheus/exporter-toolkit](https://github.com/prometheus/exporter-toolkit) from 0.11.0 to 0.12.0. - [Release notes](https://github.com/prometheus/exporter-toolkit/releases) - [Changelog](https://github.com/prometheus/exporter-toolkit/blob/master/CHANGELOG.md) - [Commits](https://github.com/prometheus/exporter-toolkit/compare/v0.11.0...v0.12.0) --- updated-dependencies: - dependency-name: github.com/prometheus/exporter-toolkit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 20 +++++++++++--------- go.sum | 40 ++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index 206ce2a1b8..123687ad0d 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,8 @@ require ( github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.20.2 github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common v0.57.0 - github.com/prometheus/exporter-toolkit v0.11.0 + github.com/prometheus/common v0.58.0 + github.com/prometheus/exporter-toolkit v0.12.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 @@ -61,6 +61,8 @@ require ( github.com/klauspost/compress v1.17.9 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/mdlayher/socket v0.4.1 // indirect + github.com/mdlayher/vsock v1.2.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -81,14 +83,14 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.25.0 // indirect + golang.org/x/crypto v0.26.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/term v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index 90384ce168..6409b7c161 100644 --- a/go.sum +++ b/go.sum @@ -93,6 +93,10 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U= +github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= +github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ= +github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -125,10 +129,10 @@ github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjs github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.57.0 h1:Ro/rKjwdq9mZn1K5QPctzh+MA4Lp0BuYk5ZZEVhoNcY= -github.com/prometheus/common v0.57.0/go.mod h1:7uRPFSUTbfZWsJ7MHY56sqt7hLQu3bxXHDnNhl8E9qI= -github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= -github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= +github.com/prometheus/common v0.58.0 h1:N+N8vY4/23r6iYfD3UQZUoJPnUYAo7v6LG5XZxjZTXo= +github.com/prometheus/common v0.58.0/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= +github.com/prometheus/exporter-toolkit v0.12.0 h1:DkE5RcEZR3lQA2QD5JLVQIf41dFKNsVMXFhgqcif7fo= +github.com/prometheus/exporter-toolkit v0.12.0/go.mod h1:fQH0KtTn0yrrS0S82kqppRjDDiwMfIQUwT+RBRRhwUc= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= @@ -177,8 +181,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -187,27 +191,27 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= -golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= +golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 4aced25f69e00d54ec3e03a921f8bf60d4e8a783 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Thu, 5 Sep 2024 13:58:52 -0700 Subject: [PATCH 089/154] fix race condition in metrics handler Signed-off-by: Walther Lee --- pkg/metricshandler/metrics_handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index 6ae02b7a47..525c87fc0d 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -72,7 +72,10 @@ func New(opts *options.Options, kubeClient kubernetes.Interface, storeBuilder ks // ReconfigureSharding reconfigures sharding with the current shard and totalShards, and // it's a no-op if both values are 0. func (m *MetricsHandler) ReconfigureSharding(ctx context.Context) { - if m.curShard == 0 && m.curTotalShards == 0 { + m.mtx.RLock() + hasShardsSet := m.curShard != 0 || m.curTotalShards != 0 + m.mtx.RUnlock() + if !hasShardsSet { return } m.ConfigureSharding(ctx, m.curShard, m.curTotalShards) From 12a22912875a7cdeb2895b1912949e9c8da86922 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 09:27:47 +0000 Subject: [PATCH 090/154] build(deps): Bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.20.2 to 1.20.3. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/v1.20.3/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.20.2...v1.20.3) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 123687ad0d..7ffac06413 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gobuffalo/flect v1.0.2 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 - github.com/prometheus/client_golang v1.20.2 + github.com/prometheus/client_golang v1.20.3 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.58.0 github.com/prometheus/exporter-toolkit v0.12.0 diff --git a/go.sum b/go.sum index 6409b7c161..b7fc435f26 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= -github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4= +github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.58.0 h1:N+N8vY4/23r6iYfD3UQZUoJPnUYAo7v6LG5XZxjZTXo= From 3dced14afe795df65c4c78b08f1252361cdc06b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 09:37:14 +0000 Subject: [PATCH 091/154] build(deps): Bump github.com/prometheus/common from 0.58.0 to 0.59.1 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.58.0 to 0.59.1. - [Release notes](https://github.com/prometheus/common/releases) - [Changelog](https://github.com/prometheus/common/blob/main/RELEASE.md) - [Commits](https://github.com/prometheus/common/compare/v0.58.0...v0.59.1) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7ffac06413..9bec07170b 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.20.3 github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common v0.58.0 + github.com/prometheus/common v0.59.1 github.com/prometheus/exporter-toolkit v0.12.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.1 diff --git a/go.sum b/go.sum index b7fc435f26..3a639ffb4a 100644 --- a/go.sum +++ b/go.sum @@ -129,8 +129,8 @@ github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0q github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.58.0 h1:N+N8vY4/23r6iYfD3UQZUoJPnUYAo7v6LG5XZxjZTXo= -github.com/prometheus/common v0.58.0/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= +github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= +github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= github.com/prometheus/exporter-toolkit v0.12.0 h1:DkE5RcEZR3lQA2QD5JLVQIf41dFKNsVMXFhgqcif7fo= github.com/prometheus/exporter-toolkit v0.12.0/go.mod h1:fQH0KtTn0yrrS0S82kqppRjDDiwMfIQUwT+RBRRhwUc= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= From 3a10a4ee2e1b1673df23a3464bdcf8792309dc6a Mon Sep 17 00:00:00 2001 From: Samuel Alfageme Sainz Date: Mon, 9 Sep 2024 18:30:58 +0200 Subject: [PATCH 092/154] Fix unformatted code blocks in README --- README.md | 13 ++++++++----- README.md.tpl | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 993a9bdb11..7ad8eaa943 100644 --- a/README.md +++ b/README.md @@ -407,17 +407,20 @@ Starting from the kube-state-metrics chart `v2.13.3` (kube-state-metrics image ` #### Development -When developing, test a metric dump against your local Kubernetes cluster by -running: +When developing, test a metric dump against your local Kubernetes cluster by running: > Users can override the apiserver address in KUBE-CONFIG file with `--apiserver` command line. - go install - kube-state-metrics --port=8080 --telemetry-port=8081 --kubeconfig= --apiserver= +``` +go install +kube-state-metrics --port=8080 --telemetry-port=8081 --kubeconfig= --apiserver= +``` Then curl the metrics endpoint - curl localhost:8080/metrics +``` +curl localhost:8080/metrics +``` To run the e2e tests locally see the documentation in [tests/README.md](./tests/README.md). diff --git a/README.md.tpl b/README.md.tpl index a41d8bdc1d..4faa67be78 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -408,17 +408,20 @@ Starting from the kube-state-metrics chart `v2.13.3` (kube-state-metrics image ` #### Development -When developing, test a metric dump against your local Kubernetes cluster by -running: +When developing, test a metric dump against your local Kubernetes cluster by running: > Users can override the apiserver address in KUBE-CONFIG file with `--apiserver` command line. - go install - kube-state-metrics --port=8080 --telemetry-port=8081 --kubeconfig= --apiserver= +``` +go install +kube-state-metrics --port=8080 --telemetry-port=8081 --kubeconfig= --apiserver= +``` Then curl the metrics endpoint - curl localhost:8080/metrics +``` +curl localhost:8080/metrics +``` To run the e2e tests locally see the documentation in [tests/README.md](./tests/README.md). From f34cd69cee7c2b9e8a151899a5902a3cae5dda1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 30 Aug 2024 22:43:29 +0200 Subject: [PATCH 093/154] chore: Bump go to 1.23.1 --- .github/workflows/ci.yml | 4 ++-- .golangci.yml | 2 +- Makefile | 6 +++--- go.mod | 4 +--- pkg/app/server_test.go | 2 +- pkg/customresourcestate/custom_resource_metrics_test.go | 2 +- pkg/metricshandler/metrics_handler.go | 2 +- tools/go.mod | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f305704827..ed8a49aff4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,8 +20,8 @@ env: E2E_SETUP_KIND: yes E2E_SETUP_KUBECTL: yes SUDO: sudo - GO_VERSION: "^1.22" - GOLANGCI_LINT_VERSION: "v1.56.2" + GO_VERSION: "^1.23" + GOLANGCI_LINT_VERSION: "v1.61.0" jobs: ci-go-lint: diff --git a/.golangci.yml b/.golangci.yml index 15d5dd160a..d6df958fcd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - deadline: 10m + timeout: 10m linters: disable-all: true diff --git a/Makefile b/Makefile index 467b73e6b0..5a2d9889fb 100644 --- a/Makefile +++ b/Makefile @@ -15,13 +15,13 @@ GIT_COMMIT ?= $(shell git rev-parse --short HEAD) OS ?= $(shell uname -s | tr A-Z a-z) ALL_ARCH = amd64 arm arm64 ppc64le s390x PKG = github.com/prometheus/common -PROMETHEUS_VERSION = 2.53.1 -GO_VERSION = 1.22.5 +PROMETHEUS_VERSION = 2.54.1 +GO_VERSION = 1.23.1 IMAGE = $(REGISTRY)/kube-state-metrics MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) USER ?= $(shell id -u -n) HOST ?= $(shell hostname) -MARKDOWNLINT_CLI2_VERSION = 0.13.0 +MARKDOWNLINT_CLI2_VERSION = 0.14.0 export DOCKER_CLI_EXPERIMENTAL=enabled diff --git a/go.mod b/go.mod index 9bec07170b..1d5917990b 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module k8s.io/kube-state-metrics/v2 -go 1.22.0 - -toolchain go1.22.5 +go 1.23.0 require ( github.com/KimMachineGun/automemlimit v0.6.1 diff --git a/pkg/app/server_test.go b/pkg/app/server_test.go index f7d33bac85..9f6c0be970 100644 --- a/pkg/app/server_test.go +++ b/pkg/app/server_test.go @@ -861,7 +861,7 @@ func pod(client *fake.Clientset, index int) error { func foo(client *samplefake.Clientset, index int) error { i := strconv.Itoa(index) - desiredReplicas := int32(index) + desiredReplicas := int32(index) //nolint:gosec foo := samplev1alpha1.Foo{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/customresourcestate/custom_resource_metrics_test.go b/pkg/customresourcestate/custom_resource_metrics_test.go index 31121de75c..fa31029922 100644 --- a/pkg/customresourcestate/custom_resource_metrics_test.go +++ b/pkg/customresourcestate/custom_resource_metrics_test.go @@ -229,7 +229,7 @@ func TestNewCustomResourceMetrics(t *testing.T) { t.Run(tt.name, func(t *testing.T) { v, err := NewCustomResourceMetrics(tt.r) if err != nil { - t.Errorf(err.Error()) + t.Error(err.Error()) } // convert to JSON for easier nil comparison diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index e944033c12..9d02dd0b95 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -256,7 +256,7 @@ func detectNominalFromPod(statefulSetName, podName string) (int32, error) { return 0, fmt.Errorf("failed to detect shard index for Pod %s of StatefulSet %s, parsed %s: %w", podName, statefulSetName, nominalString, err) } - return int32(nominal), nil + return int32(nominal), nil //nolint:gosec } func detectStatefulSet(kubeClient kubernetes.Interface, podName, namespaceName string) (*appsv1.StatefulSet, error) { diff --git a/tools/go.mod b/tools/go.mod index 8f25270889..302640a667 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,6 +1,6 @@ module k8s.io/kube-state-metrics/v2/tools -go 1.21 +go 1.23.0 require ( github.com/brancz/gojsontoyaml v0.1.0 From 1a1ca73eca87a691dcc7a27298b744e6e0bec9f8 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Thu, 12 Sep 2024 12:38:08 -0700 Subject: [PATCH 094/154] decouple BuildWriters from ConfigureSharding Signed-off-by: Walther Lee --- internal/discovery/discovery.go | 2 +- pkg/metricshandler/metrics_handler.go | 28 +++++++++++++-------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index ab778113b3..7e1f162909 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -236,7 +236,7 @@ func (r *CRDiscoverer) PollForCacheUpdates( r.WasUpdated = false }) // Update metric handler with the new configs. - m.ReconfigureSharding(ctx) + m.BuildWriters(ctx) } go func() { for range t.C { diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index bb7d06b68e..1ff253f2e2 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -71,34 +71,32 @@ func New(opts *options.Options, kubeClient kubernetes.Interface, storeBuilder ks // ReconfigureSharding reconfigures sharding with the current shard and totalShards, and // it's a no-op if both values are 0. -func (m *MetricsHandler) ReconfigureSharding(ctx context.Context) { - m.mtx.RLock() - hasShardsSet := m.curShard != 0 || m.curTotalShards != 0 - m.mtx.RUnlock() - if !hasShardsSet { - return +func (m *MetricsHandler) BuildWriters(ctx context.Context) { + m.mtx.Lock() + defer m.mtx.Unlock() + + if m.cancel != nil { + m.cancel() } - m.ConfigureSharding(ctx, m.curShard, m.curTotalShards) + ctx, m.cancel = context.WithCancel(ctx) + m.storeBuilder.WithContext(ctx) + m.metricsWriters = m.storeBuilder.Build() } // ConfigureSharding configures sharding. Configuration can be used mutlitple times and // concurrently. func (m *MetricsHandler) ConfigureSharding(ctx context.Context, shard int32, totalShards int) { m.mtx.Lock() - defer m.mtx.Unlock() - if m.cancel != nil { - m.cancel() - } if totalShards != 1 { klog.InfoS("Configuring sharding of this instance to be shard index (zero-indexed) out of total shards", "shard", shard, "totalShards", totalShards) } - ctx, m.cancel = context.WithCancel(ctx) - m.storeBuilder.WithSharding(shard, totalShards) - m.storeBuilder.WithContext(ctx) - m.metricsWriters = m.storeBuilder.Build() m.curShard = shard m.curTotalShards = totalShards + m.storeBuilder.WithSharding(shard, totalShards) + m.mtx.Unlock() + + m.BuildWriters(ctx) } // Run configures the MetricsHandler's sharding and if autosharding is enabled From 012121e50e99c8fa52f58e2495986ccea129e0cf Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Thu, 12 Sep 2024 12:39:53 -0700 Subject: [PATCH 095/154] update func docstring Signed-off-by: Walther Lee --- pkg/metricshandler/metrics_handler.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index 1ff253f2e2..76d83f0ccf 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -69,8 +69,8 @@ func New(opts *options.Options, kubeClient kubernetes.Interface, storeBuilder ks } } -// ReconfigureSharding reconfigures sharding with the current shard and totalShards, and -// it's a no-op if both values are 0. +// BuildWriters builds the metrics writers, cancelling any previous context and passing a new one on every build. +// Build can be used mutlitple times and concurrently. func (m *MetricsHandler) BuildWriters(ctx context.Context) { m.mtx.Lock() defer m.mtx.Unlock() @@ -94,8 +94,9 @@ func (m *MetricsHandler) ConfigureSharding(ctx context.Context, shard int32, tot m.curShard = shard m.curTotalShards = totalShards m.storeBuilder.WithSharding(shard, totalShards) - m.mtx.Unlock() + // unlock because BuildWriters will hold a lock again + m.mtx.Unlock() m.BuildWriters(ctx) } From 9aad0c02f3d8a92c468dc91cb6fe7cb0543bbf54 Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Fri, 13 Sep 2024 12:30:56 -0700 Subject: [PATCH 096/154] fix resource duplication in store builder Signed-off-by: Walther Lee --- internal/store/builder.go | 20 ++-- tests/e2e/discovery_test.go | 189 ++++++++++++++++++++++++++++++------ 2 files changed, 176 insertions(+), 33 deletions(-) diff --git a/internal/store/builder.go b/internal/store/builder.go index f7941794e4..27f43ab3c3 100644 --- a/internal/store/builder.go +++ b/internal/store/builder.go @@ -107,18 +107,26 @@ func (b *Builder) WithMetrics(r prometheus.Registerer) { // WithEnabledResources sets the enabledResources property of a Builder. func (b *Builder) WithEnabledResources(r []string) error { + enabledResources := map[string]bool{} + for _, er := range b.enabledResources { + enabledResources[er] = true + } + var newResources []string for _, resource := range r { + // validate that the resource exists and skip those that are already enabled if !resourceExists(resource) { return fmt.Errorf("resource %s does not exist. Available resources: %s", resource, strings.Join(availableResources(), ",")) } + if _, ok := enabledResources[resource]; !ok { + newResources = append(newResources, resource) + } + } + if len(newResources) == 0 { + return nil } - var sortedResources []string - sortedResources = append(sortedResources, r...) - - sort.Strings(sortedResources) - - b.enabledResources = append(b.enabledResources, sortedResources...) + b.enabledResources = append(b.enabledResources, newResources...) + sort.Strings(b.enabledResources) return nil } diff --git a/tests/e2e/discovery_test.go b/tests/e2e/discovery_test.go index d34c932daf..1722e42aba 100644 --- a/tests/e2e/discovery_test.go +++ b/tests/e2e/discovery_test.go @@ -49,15 +49,23 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) { if err != nil { t.Fatal(err) } - crdFile, err := os.CreateTemp("", "crd.yaml") + initCrdFile, err := os.CreateTemp("", "crd.yaml") if err != nil { t.Fatal(err) } - crFile, err := os.CreateTemp("", "cr.yaml") + initCrFile, err := os.CreateTemp("", "cr.yaml") if err != nil { t.Fatal(err) } - klog.InfoS("testdata", "crConfigFile", crConfigFile.Name(), "crdFile", crdFile.Name(), "crFile", crFile.Name()) + newCrdFile, err := os.CreateTemp("", "new-crd.yaml") + if err != nil { + t.Fatal(err) + } + newCrFile, err := os.CreateTemp("", "new-cr.yaml") + if err != nil { + t.Fatal(err) + } + klog.InfoS("testdata", "crConfigFile", crConfigFile.Name(), "initCrdFile", initCrdFile.Name(), "initCrFile", initCrFile.Name(), "newCrdFile", newCrdFile.Name(), "newCrFile", newCrFile.Name()) // Delete artefacts. defer func() { @@ -65,15 +73,23 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) { if err != nil { t.Fatalf("failed to remove CR config: %v", err) } - err = os.Remove(crdFile.Name()) + err = os.Remove(initCrdFile.Name()) + if err != nil { + t.Fatalf("failed to remove initial CRD manifest: %v", err) + } + err = os.Remove(initCrFile.Name()) + if err != nil { + t.Fatalf("failed to remove initial CR manifest: %v", err) + } + err = os.Remove(newCrdFile.Name()) if err != nil { - t.Fatalf("failed to remove CRD manifest: %v", err) + t.Fatalf("failed to remove new CRD manifest: %v", err) } - err = os.Remove(crFile.Name()) + err = os.Remove(newCrFile.Name()) if err != nil { - t.Fatalf("failed to remove CR manifest: %v", err) + t.Fatalf("failed to remove new CR manifest: %v", err) } - klog.InfoS("deleted artefacts", "crConfigFile", crConfigFile.Name(), "crdFile", crdFile.Name(), "crFile", crFile.Name()) + klog.InfoS("deleted artefacts", "crConfigFile", crConfigFile.Name(), "initCrdFile", initCrdFile.Name(), "initCrFile", initCrFile.Name(), "newCrdFile", newCrdFile.Name(), "newCrFile", newCrFile.Name()) }() // Populate options, and parse them. @@ -114,32 +130,92 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) { klog.InfoS("port 8080 up") // Create CRD and CR files. - crd := getCRD() - cr := getCR() - err = os.WriteFile(crdFile.Name(), []byte(crd), 0600 /* rw------- */) + initCr := getCR() + initCrd := getCRD() + + newCr := getNewCR() + newCrd := getNewCRD() + err = os.WriteFile(initCrdFile.Name(), []byte(initCrd), 0600 /* rw------- */) if err != nil { - t.Fatalf("cannot write to crd file: %v", err) + t.Fatalf("cannot write to initial crd file: %v", err) } - err = os.WriteFile(crFile.Name(), []byte(cr), 0600 /* rw------- */) + err = os.WriteFile(initCrFile.Name(), []byte(initCr), 0600 /* rw------- */) if err != nil { - t.Fatalf("cannot write to cr file: %v", err) + t.Fatalf("cannot write to initial cr file: %v", err) } - klog.InfoS("created CR and CRD manifests") + err = os.WriteFile(newCrdFile.Name(), []byte(newCrd), 0600 /* rw------- */) + if err != nil { + t.Fatalf("cannot write to new crd file: %v", err) + } + err = os.WriteFile(newCrFile.Name(), []byte(newCr), 0600 /* rw------- */) + if err != nil { + t.Fatalf("cannot write to new cr file: %v", err) + } + klog.InfoS("created initial and new CR and CRD manifests") - // Apply CRD and CR to the cluster. - err = exec.Command("kubectl", "apply", "-f", crdFile.Name()).Run() //nolint:gosec + // Apply initial CRD and CR to the cluster. + err = exec.Command("kubectl", "apply", "-f", initCrdFile.Name()).Run() //nolint:gosec if err != nil { - t.Fatalf("failed to apply crd: %v", err) + t.Fatalf("failed to apply initial crd: %v", err) } - err = exec.Command("kubectl", "apply", "-f", crFile.Name()).Run() //nolint:gosec + err = exec.Command("kubectl", "apply", "-f", initCrFile.Name()).Run() //nolint:gosec if err != nil { - t.Fatalf("failed to apply cr: %v", err) + t.Fatalf("failed to apply initial cr: %v", err) } - klog.InfoS("applied CR and CRD manifests") + klog.InfoS("applied initial CR and CRD manifests") // Wait for the metric to be available. ch := make(chan bool, 1) - klog.InfoS("waiting for metrics to become available") + klog.InfoS("waiting for first metrics to become available") + testMetric := `kube_customresource_test_metric{customresource_group="contoso.com",customresource_kind="MyPlatform",customresource_version="v1alpha1",name="test-dotnet-app"}` + err = wait.PollUntilContextTimeout(context.TODO(), discovery.Interval, PopulateTimeout, true, func(_ context.Context) (bool, error) { + out, err := exec.Command("curl", "localhost:8080/metrics").Output() + if err != nil { + return false, err + } + if string(out) == "" { + return false, nil + } + // Note: we use count to make sure that only one metrics handler is running + if strings.Count(string(out), testMetric) == 1 { + // klog.InfoS("metrics available", "metric", string(out)) + // Signal the process to exit, since we know the metrics are being generated as expected. + ch <- true + return true, nil + } + return false, nil + }) + if err != nil { + t.Fatalf("failed while waiting for initial metrics to be available: %v", err) + } + + // Wait for process to exit. + select { + case <-ch: + t.Log("initial metrics are available") + case <-time.After(PopulateTimeout * 2): + t.Fatal("timed out waiting for test to pass, check the logs for more info") + } + + // Apply new CRD and CR to the cluster. + err = exec.Command("kubectl", "apply", "-f", newCrdFile.Name()).Run() //nolint:gosec + if err != nil { + t.Fatalf("failed to apply new crd: %v", err) + } + err = exec.Command("kubectl", "apply", "-f", newCrFile.Name()).Run() //nolint:gosec + if err != nil { + t.Fatalf("failed to apply new cr: %v", err) + } + err = exec.Command("kubectl", "delete", "myplatform", "test-dotnet-app").Run() //nolint:gosec + if err != nil { + t.Fatalf("failed to delete myplatform resource: %v", err) + } + klog.InfoS("applied new CR and CRD manifests") + + // Wait for the the new metric to be available + ch = make(chan bool, 1) + klog.InfoS("waiting for new metrics to become available") + testUpdateCRDMetric := `kube_customresource_test_update_crd_metric{customresource_group="contoso.com",customresource_kind="Update",customresource_version="v1",name="test-dotnet-app-update"}` err = wait.PollUntilContextTimeout(context.TODO(), discovery.Interval, PopulateTimeout, true, func(_ context.Context) (bool, error) { out, err := exec.Command("curl", "localhost:8080/metrics").Output() if err != nil { @@ -148,17 +224,20 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) { if string(out) == "" { return false, nil } - // Note the "{" below. This is to ensure that the metric is not in a comment. - if strings.Contains(string(out), "kube_customresource_test_metric{") { + // Note: we use count to make sure that only one metrics handler is running, and we also want to validate that the + // new metric is available and the old one was removed, otherwise, the response could come from the + // previous handler before its context was cancelled, or maybe because it failed to be cancelled. + if strings.Count(string(out), testUpdateCRDMetric) == 1 && !strings.Contains(string(out), testMetric) { klog.InfoS("metrics available", "metric", string(out)) // Signal the process to exit, since we know the metrics are being generated as expected. ch <- true return true, nil } + klog.InfoS("metrics available", "metric", string(out)) return false, nil }) if err != nil { - t.Fatalf("failed while waiting for metrics to be available: %v", err) + t.Fatalf("failed while waiting for new metrics to be available: %v", err) } // Wait for process to exit. @@ -252,8 +331,8 @@ spec: resources: - groupVersionKind: group: "contoso.com" - version: "*" - kind: "*" + version: "v1alpha1" + kind: "MyPlatform" metrics: - name: "test_metric" help: "foo baz" @@ -263,5 +342,61 @@ spec: path: [metadata] labelsFromPath: name: [name] + - groupVersionKind: + group: "contoso.com" + version: "v1" + kind: "Update" + metrics: + - name: "test_update_crd_metric" + help: "foo baz" + each: + type: Info + info: + path: [metadata] + labelsFromPath: + name: [name] +` +} + +func getNewCR() string { + return ` +apiVersion: contoso.com/v1 +kind: Update +metadata: + name: test-dotnet-app-update +spec: + new: just-added +` +} + +func getNewCRD() string { + return ` +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: updates.contoso.com +spec: + group: contoso.com + names: + plural: updates + singular: update + kind: Update + shortNames: + - updt + scope: Namespaced + versions: + - name: v1 + served: true + storage: true + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + new: + type: string + required: ["spec"] ` } From 24c2194e7e6e9d2a7290d3a872abf42f6086c276 Mon Sep 17 00:00:00 2001 From: Chris Bartlett Date: Wed, 18 Sep 2024 17:22:38 -0600 Subject: [PATCH 097/154] fix: deduplication of cr enabled resources --- internal/store/builder.go | 10 +++---- internal/store/builder_test.go | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/internal/store/builder.go b/internal/store/builder.go index f7941794e4..3b253295c1 100644 --- a/internal/store/builder.go +++ b/internal/store/builder.go @@ -20,7 +20,7 @@ import ( "context" "fmt" "reflect" - "sort" + "slices" "strconv" "strings" "time" @@ -113,12 +113,10 @@ func (b *Builder) WithEnabledResources(r []string) error { } } - var sortedResources []string - sortedResources = append(sortedResources, r...) + b.enabledResources = append(b.enabledResources, r...) + slices.Sort(b.enabledResources) + b.enabledResources = slices.Compact(b.enabledResources) - sort.Strings(sortedResources) - - b.enabledResources = append(b.enabledResources, sortedResources...) return nil } diff --git a/internal/store/builder_test.go b/internal/store/builder_test.go index 3bb5dea3aa..323e5b76c3 100644 --- a/internal/store/builder_test.go +++ b/internal/store/builder_test.go @@ -18,6 +18,7 @@ package store import ( "reflect" + "slices" "testing" "k8s.io/kube-state-metrics/v2/pkg/options" @@ -196,3 +197,56 @@ func TestWithAllowAnnotations(t *testing.T) { } } } + +func TestWithEnabledResources(t *testing.T) { + + tests := []struct { + Desc string + EnabledResources []string + Wanted []string + err expectedError + }{ + { + Desc: "sorts enabled resources", + EnabledResources: []string{"pods", "cronjobs", "deployments"}, + Wanted: []string{ + "cronjobs", + "deployments", + "pods", + }, + }, + { + Desc: "de-duplicates enabled resources", + EnabledResources: []string{"pods", "cronjobs", "deployments", "pods"}, + Wanted: []string{ + "cronjobs", + "deployments", + "pods", + }, + }, + { + Desc: "error if not exist", + EnabledResources: []string{"pods", "cronjobs", "deployments", "foo"}, + Wanted: []string{}, + err: expectedError{ + expectedResourceError: true, + }, + }, + } + for _, test := range tests { + b := NewBuilder() + + // Set the enabled resources. + err := b.WithEnabledResources(test.EnabledResources) + if err != nil && !test.err.expectedResourceError { + t.Log("Did not expect error while setting resources (--resources).") + t.Errorf("Test error for Desc: %s. Got Error: %v", test.Desc, err) + } + + // Evaluate. + if !slices.Equal(b.enabledResources, test.Wanted) && err == nil { + t.Log("Expected enabled resources to be equal.") + t.Errorf("Test error for Desc: %s\n Want: \n%+v\n Got: \n%#+v", test.Desc, test.Wanted, b.enabledResources) + } + } +} From f2ab628d2bb5c89afa42b2e7a6c41b71e805938c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:23:49 +0000 Subject: [PATCH 098/154] build(deps): Bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.20.3 to 1.20.4. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.20.3...v1.20.4) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1d5917990b..e66dc9a5e5 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/gobuffalo/flect v1.0.2 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 - github.com/prometheus/client_golang v1.20.3 + github.com/prometheus/client_golang v1.20.4 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.59.1 github.com/prometheus/exporter-toolkit v0.12.0 diff --git a/go.sum b/go.sum index 3a639ffb4a..f12652989e 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4= -github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= From 9322447ced2a011d7f28b60781b815a8c1c5b10d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:04:56 +0000 Subject: [PATCH 099/154] build(deps): Bump github.com/gobuffalo/flect from 1.0.2 to 1.0.3 Bumps [github.com/gobuffalo/flect](https://github.com/gobuffalo/flect) from 1.0.2 to 1.0.3. - [Release notes](https://github.com/gobuffalo/flect/releases) - [Commits](https://github.com/gobuffalo/flect/compare/v1.0.2...v1.0.3) --- updated-dependencies: - dependency-name: github.com/gobuffalo/flect dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e66dc9a5e5..84e9d04e62 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/KimMachineGun/automemlimit v0.6.1 github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 github.com/fsnotify/fsnotify v1.7.0 - github.com/gobuffalo/flect v1.0.2 + github.com/gobuffalo/flect v1.0.3 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.20.4 diff --git a/go.sum b/go.sum index f12652989e..945b5d8c8a 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,8 @@ github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/ github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= -github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= +github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= +github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= From 4b420cb6f7818a2b9b187b00441181fe41e46e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 23 Sep 2024 22:12:23 +0200 Subject: [PATCH 100/154] chore: Migrate to slog --- go.mod | 6 ++---- go.sum | 8 ++------ pkg/app/server.go | 29 ++++++++++++----------------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index 84e9d04e62..3e97a79212 100644 --- a/go.mod +++ b/go.mod @@ -6,13 +6,14 @@ require ( github.com/KimMachineGun/automemlimit v0.6.1 github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 github.com/fsnotify/fsnotify v1.7.0 + github.com/go-logr/logr v1.4.1 github.com/gobuffalo/flect v1.0.3 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.20.4 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.59.1 - github.com/prometheus/exporter-toolkit v0.12.0 + github.com/prometheus/exporter-toolkit v0.13.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 @@ -38,9 +39,6 @@ require ( github.com/docker/go-units v0.4.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect - github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect - github.com/go-logr/logr v1.4.1 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect diff --git a/go.sum b/go.sum index 945b5d8c8a..ef4cc1664d 100644 --- a/go.sum +++ b/go.sum @@ -30,10 +30,6 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= @@ -131,8 +127,8 @@ github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= -github.com/prometheus/exporter-toolkit v0.12.0 h1:DkE5RcEZR3lQA2QD5JLVQIf41dFKNsVMXFhgqcif7fo= -github.com/prometheus/exporter-toolkit v0.12.0/go.mod h1:fQH0KtTn0yrrS0S82kqppRjDDiwMfIQUwT+RBRRhwUc= +github.com/prometheus/exporter-toolkit v0.13.0 h1:lmA0Q+8IaXgmFRKw09RldZmZdnvu9wwcDLIXGmTPw1c= +github.com/prometheus/exporter-toolkit v0.13.0/go.mod h1:2uop99EZl80KdXhv/MxVI2181fMcwlsumFOqBecGkG0= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= diff --git a/pkg/app/server.go b/pkg/app/server.go index 98bb11df01..56afc6090a 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -21,6 +21,7 @@ import ( "crypto/md5" //nolint:gosec "encoding/binary" "fmt" + "log/slog" "net" "net/http" "net/http/pprof" @@ -30,6 +31,8 @@ import ( "strings" "time" + "github.com/go-logr/logr" + "gopkg.in/yaml.v3" "k8s.io/client-go/kubernetes" _ "k8s.io/client-go/plugin/pkg/client/auth" // Initialize common client auth plugins. @@ -66,19 +69,6 @@ const ( readyzPath = "/readyz" ) -// promLogger implements promhttp.Logger -type promLogger struct{} - -func (pl promLogger) Println(v ...interface{}) { - klog.Error(v...) -} - -// promLogger implements the Logger interface -func (pl promLogger) Log(v ...interface{}) error { - klog.Info(v...) - return nil -} - // RunKubeStateMetricsWrapper runs KSM with context cancellation. func RunKubeStateMetricsWrapper(ctx context.Context, opts *options.Options) error { err := RunKubeStateMetrics(ctx, opts) @@ -93,7 +83,6 @@ func RunKubeStateMetricsWrapper(ctx context.Context, opts *options.Options) erro // Any out-of-tree custom resource metrics could be registered by newing a registry factory // which implements customresource.RegistryFactory and pass all factories into this function. func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { - promLogger := promLogger{} ksmMetricsRegistry := prometheus.NewRegistry() ksmMetricsRegistry.MustRegister(versionCollector.NewCollector("kube_state_metrics")) durationVec := promauto.With(ksmMetricsRegistry).NewHistogramVec( @@ -361,11 +350,14 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { WebConfigFile: &tlsConfig, } + handler := logr.ToSlogHandler(klog.Background()) + sLogger := slog.New(handler) + // Run Telemetry server { g.Add(func() error { klog.InfoS("Started kube-state-metrics self metrics server", "telemetryAddress", telemetryListenAddress) - return web.ListenAndServe(&telemetryServer, &telemetryFlags, promLogger) + return web.ListenAndServe(&telemetryServer, &telemetryFlags, sLogger) }, func(error) { ctxShutDown, cancel := context.WithTimeout(ctx, 3*time.Second) defer cancel() @@ -376,7 +368,7 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { { g.Add(func() error { klog.InfoS("Started metrics server", "metricsServerAddress", metricsServerListenAddress) - return web.ListenAndServe(&metricsServer, &metricsFlags, promLogger) + return web.ListenAndServe(&metricsServer, &metricsFlags, sLogger) }, func(error) { ctxShutDown, cancel := context.WithTimeout(ctx, 3*time.Second) defer cancel() @@ -395,8 +387,11 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { func buildTelemetryServer(registry prometheus.Gatherer) *http.ServeMux { mux := http.NewServeMux() + handler := logr.ToSlogHandler(klog.Background()) + sLogger := slog.NewLogLogger(handler, slog.LevelError) + // Add metricsPath - mux.Handle(metricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{ErrorLog: promLogger{}})) + mux.Handle(metricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{ErrorLog: sLogger})) // Add readyzPath mux.Handle(readyzPath, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { From f7ec4da61814713c9843336784a5fbc153a627cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 30 Aug 2024 22:15:25 +0200 Subject: [PATCH 101/154] chore: Bump to kubernetes 1.31 Breaking change for node metrics, as kube-proxy field is deprecated and contains invalid information. See also https://kubernetes.io/blog/2024/07/19/kubernetes-1-31-upcoming-changes/#deprecation-of-status-nodeinfo-kubeproxyversion-field-for-nodes-kep-4004-https-github-com-kubernetes-enhancements-issues-4004 --- README.md | 2 +- data.yaml | 2 +- docs/metrics/cluster/node-metrics.md | 2 +- go.mod | 24 +++++----- go.sum | 67 +++++++++++++++------------- internal/store/node.go | 2 +- internal/store/node_test.go | 6 +-- tests/e2e.sh | 2 +- 8 files changed, 57 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 7ad8eaa943..d67173c677 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Generally, it is recommended to use the latest release of kube-state-metrics. If | **v2.11.0** | v1.28 | | **v2.12.0** | v1.29 | | **v2.13.0** | v1.30 | -| **main** | v1.30 | +| **main** | v1.31 | #### Resource group version compatibility diff --git a/data.yaml b/data.yaml index a5876cd726..b20061e763 100644 --- a/data.yaml +++ b/data.yaml @@ -16,4 +16,4 @@ compat: - version: "v2.13.0" kubernetes: "1.30" - version: "main" - kubernetes: "1.30" + kubernetes: "1.31" diff --git a/docs/metrics/cluster/node-metrics.md b/docs/metrics/cluster/node-metrics.md index ac1085bf8e..63d4d76b81 100644 --- a/docs/metrics/cluster/node-metrics.md +++ b/docs/metrics/cluster/node-metrics.md @@ -3,7 +3,7 @@ | Metric name | Metric type | Description | Unit (where applicable) | Labels/tags | Status | | ---------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | | kube_node_annotations | Gauge | Kubernetes annotations converted to Prometheus labels controlled via [--metric-annotations-allowlist](../../developer/cli-arguments.md) | | `node`=<node-address>
`annotation_NODE_ANNOTATION`=<NODE_ANNOTATION> | EXPERIMENTAL | -| kube_node_info | Gauge | Information about a cluster node | | `node`=<node-address>
`kernel_version`=<kernel-version>
`os_image`=<os-image-name>
`container_runtime_version`=<container-runtime-and-version-combination>
`kubelet_version`=<kubelet-version>
`kubeproxy_version`=<kubeproxy-version>
`pod_cidr`=<pod-cidr>
`provider_id`=<provider-id>
`system_uuid`=<system-uuid>
`internal_ip`=<internal-ip> | STABLE | +| kube_node_info | Gauge | Information about a cluster node | | `node`=<node-address>
`kernel_version`=<kernel-version>
`os_image`=<os-image-name>
`container_runtime_version`=<container-runtime-and-version-combination>
`kubelet_version`=<kubelet-version>
`kubeproxy_version`=<deprecated>
`pod_cidr`=<pod-cidr>
`provider_id`=<provider-id>
`system_uuid`=<system-uuid>
`internal_ip`=<internal-ip> | STABLE | | kube_node_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | | `node`=<node-address>
`label_NODE_LABEL`=<NODE_LABEL> | STABLE | | kube_node_role | Gauge | The role of a cluster node | | `node`=<node-address>
`role`=<NODE_ROLE> | EXPERIMENTAL | | kube_node_spec_unschedulable | Gauge | Whether a node can schedule new pods | | `node`=<node-address> | STABLE | diff --git a/go.mod b/go.mod index 3e97a79212..2bdcd7369d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/KimMachineGun/automemlimit v0.6.1 github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 github.com/fsnotify/fsnotify v1.7.0 - github.com/go-logr/logr v1.4.1 + github.com/go-logr/logr v1.4.2 github.com/gobuffalo/flect v1.0.3 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 @@ -19,13 +19,13 @@ require ( github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.30.3 - k8s.io/apimachinery v0.30.3 - k8s.io/client-go v0.30.3 - k8s.io/component-base v0.30.3 + k8s.io/api v0.31.1 + k8s.io/apimachinery v0.31.1 + k8s.io/client-go v0.31.1 + k8s.io/component-base v0.31.1 k8s.io/klog/v2 v2.130.1 - k8s.io/sample-controller v0.30.3 - k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 + k8s.io/sample-controller v0.31.1 + k8s.io/utils v0.0.0-20240821151609-f90d01438635 ) require ( @@ -38,16 +38,16 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/docker/go-units v0.4.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch v5.6.0+incompatible // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-openapi/swag v0.22.4 // indirect github.com/godbus/dbus/v5 v5.0.4 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/imdario/mergo v0.3.6 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -78,6 +78,7 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/x448/float16 v0.8.4 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.26.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect @@ -89,11 +90,12 @@ require ( golang.org/x/text v0.17.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index ef4cc1664d..a2b6b4df7a 100644 --- a/go.sum +++ b/go.sum @@ -24,22 +24,23 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= -github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= @@ -56,10 +57,10 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2Rrd27c3VGxi6a/6HNq8QmHRKM= +github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= @@ -106,10 +107,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= -github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= -github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= -github.com/onsi/gomega v1.31.0 h1:54UJxxj6cPInHS3a35wm6BK/F9nHYueZ1NVujHDrnXE= -github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= +github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= +github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= +github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= +github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0= github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= @@ -133,8 +134,8 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= @@ -168,6 +169,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= @@ -225,6 +228,8 @@ google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWn gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= @@ -235,25 +240,25 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.30.3 h1:ImHwK9DCsPA9uoU3rVh4QHAHHK5dTSv1nxJUapx8hoQ= -k8s.io/api v0.30.3/go.mod h1:GPc8jlzoe5JG3pb0KJCSLX5oAFIW3/qNJITlDj8BH04= -k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc= -k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/client-go v0.30.3 h1:bHrJu3xQZNXIi8/MoxYtZBBWQQXwy16zqJwloXXfD3k= -k8s.io/client-go v0.30.3/go.mod h1:8d4pf8vYu665/kUbsxWAQ/JDBNWqfFeZnvFiVdmx89U= -k8s.io/component-base v0.30.3 h1:Ci0UqKWf4oiwy8hr1+E3dsnliKnkMLZMVbWzeorlk7s= -k8s.io/component-base v0.30.3/go.mod h1:C1SshT3rGPCuNtBs14RmVD2xW0EhRSeLvBh7AGk1quA= +k8s.io/api v0.31.1 h1:Xe1hX/fPW3PXYYv8BlozYqw63ytA92snr96zMW9gWTU= +k8s.io/api v0.31.1/go.mod h1:sbN1g6eY6XVLeqNsZGLnI5FwVseTrZX7Fv3O26rhAaI= +k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U= +k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/client-go v0.31.1 h1:f0ugtWSbWpxHR7sjVpQwuvw9a3ZKLXX0u0itkFXufb0= +k8s.io/client-go v0.31.1/go.mod h1:sKI8871MJN2OyeqRlmA4W4KM9KBdBUpDLu/43eGemCg= +k8s.io/component-base v0.31.1 h1:UpOepcrX3rQ3ab5NB6g5iP0tvsgJWzxTyAo20sgYSy8= +k8s.io/component-base v0.31.1/go.mod h1:WGeaw7t/kTsqpVTaCoVEtillbqAhF2/JgvO0LDOMa0w= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= -k8s.io/sample-controller v0.30.3 h1:oZTxERF8U3gANT2H5VxpkW32asgmW0IYGyUv9Opspvs= -k8s.io/sample-controller v0.30.3/go.mod h1:yhy/cWCzevQLa2+7Gvj0J9+xzmNExypunffSNANBy7o= -k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= -k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/sample-controller v0.31.1 h1:PTVmLuBqduC78vQLA+RZhs80OgYLXaMXeGsoSftUHRg= +k8s.io/sample-controller v0.31.1/go.mod h1:hyJVSX8dSwJOe0xhvqufFB9m/STgXhemLMc82If4WSU= +k8s.io/utils v0.0.0-20240821151609-f90d01438635 h1:2wThSvJoW/Ncn9TmQEYXRnevZXi2duqHWf5OX9S3zjI= +k8s.io/utils v0.0.0-20240821151609-f90d01438635/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/internal/store/node.go b/internal/store/node.go index d059e20df7..7e2919e522 100644 --- a/internal/store/node.go +++ b/internal/store/node.go @@ -152,7 +152,7 @@ func createNodeInfoFamilyGenerator() generator.FamilyGenerator { n.Status.NodeInfo.OSImage, n.Status.NodeInfo.ContainerRuntimeVersion, n.Status.NodeInfo.KubeletVersion, - n.Status.NodeInfo.KubeProxyVersion, + "deprecated", n.Spec.ProviderID, n.Spec.PodCIDR, n.Status.NodeInfo.SystemUUID, diff --git a/internal/store/node_test.go b/internal/store/node_test.go index 6457aef20e..bab5670c8f 100644 --- a/internal/store/node_test.go +++ b/internal/store/node_test.go @@ -60,7 +60,7 @@ func TestNodeStore(t *testing.T) { # TYPE kube_node_info gauge # TYPE kube_node_labels gauge # TYPE kube_node_spec_unschedulable gauge - kube_node_info{container_runtime_version="rkt",kernel_version="kernel",kubelet_version="kubelet",kubeproxy_version="kubeproxy",node="127.0.0.1",os_image="osimage",pod_cidr="172.24.10.0/24",provider_id="provider://i-uniqueid",internal_ip="1.2.3.4",system_uuid="6a934e21-5207-4a84-baea-3a952d926c80"} 1 + kube_node_info{container_runtime_version="rkt",kernel_version="kernel",kubelet_version="kubelet",kubeproxy_version="deprecated",node="127.0.0.1",os_image="osimage",pod_cidr="172.24.10.0/24",provider_id="provider://i-uniqueid",internal_ip="1.2.3.4",system_uuid="6a934e21-5207-4a84-baea-3a952d926c80"} 1 kube_node_spec_unschedulable{node="127.0.0.1"} 0 `, MetricNames: []string{"kube_node_spec_unschedulable", "kube_node_labels", "kube_node_info"}, @@ -75,7 +75,7 @@ func TestNodeStore(t *testing.T) { Want: ` # HELP kube_node_info [STABLE] Information about a cluster node. # TYPE kube_node_info gauge - kube_node_info{container_runtime_version="",kernel_version="",kubelet_version="",kubeproxy_version="",node="",os_image="",pod_cidr="",provider_id="",internal_ip="",system_uuid=""} 1 + kube_node_info{container_runtime_version="",kernel_version="",kubelet_version="",kubeproxy_version="deprecated",node="",os_image="",pod_cidr="",provider_id="",internal_ip="",system_uuid=""} 1 `, MetricNames: []string{"kube_node_info"}, }, @@ -140,7 +140,7 @@ func TestNodeStore(t *testing.T) { # TYPE kube_node_status_allocatable gauge # TYPE kube_node_status_capacity gauge kube_node_created{node="127.0.0.1"} 1.5e+09 - kube_node_info{container_runtime_version="rkt",kernel_version="kernel",kubelet_version="kubelet",kubeproxy_version="kubeproxy",node="127.0.0.1",os_image="osimage",pod_cidr="172.24.10.0/24",provider_id="provider://i-randomidentifier",internal_ip="1.2.3.4",system_uuid="6a934e21-5207-4a84-baea-3a952d926c80"} 1 + kube_node_info{container_runtime_version="rkt",kernel_version="kernel",kubelet_version="kubelet",kubeproxy_version="deprecated",node="127.0.0.1",os_image="osimage",pod_cidr="172.24.10.0/24",provider_id="provider://i-randomidentifier",internal_ip="1.2.3.4",system_uuid="6a934e21-5207-4a84-baea-3a952d926c80"} 1 kube_node_role{node="127.0.0.1",role="master"} 1 kube_node_spec_unschedulable{node="127.0.0.1"} 1 kube_node_status_allocatable{node="127.0.0.1",resource="cpu",unit="core"} 3 diff --git a/tests/e2e.sh b/tests/e2e.sh index 68928354c7..b4b34f1d2e 100755 --- a/tests/e2e.sh +++ b/tests/e2e.sh @@ -25,7 +25,7 @@ case $(uname -m) in esac NODE_IMAGE_NAME="docker.io/kindest/node" -KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.30.0"} +KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.31.0"} KUBE_STATE_METRICS_LOG_DIR=./log KUBE_STATE_METRICS_CURRENT_IMAGE_NAME="registry.k8s.io/kube-state-metrics/kube-state-metrics" KUBE_STATE_METRICS_IMAGE_NAME="registry.k8s.io/kube-state-metrics/kube-state-metrics-${ARCH}" From fb46163adda36e7118eb40d039fbeee3e63e526f Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Tue, 24 Sep 2024 12:17:58 -0700 Subject: [PATCH 102/154] fix ciclomatic complexity lint in TestVariableVKsDiscoveryAndResolution --- tests/e2e/discovery_test.go | 162 +++++++++++++++++++++--------------- 1 file changed, 97 insertions(+), 65 deletions(-) diff --git a/tests/e2e/discovery_test.go b/tests/e2e/discovery_test.go index 1722e42aba..06c0ba9ccf 100644 --- a/tests/e2e/discovery_test.go +++ b/tests/e2e/discovery_test.go @@ -36,64 +36,122 @@ import ( // PopulateTimeout is the timeout on populating the cache for the first time. const PopulateTimeout = 10 * time.Second -func TestVariableVKsDiscoveryAndResolution(t *testing.T) { - - // Initialise options. - opts := options.NewOptions() - cmd := options.InitCommand - opts.AddFlags(cmd) - klog.InfoS("options", "options", opts) +type resourceManager struct { + crConfigFile *os.File + initCrdFile *os.File + initCrFile *os.File + newCrdFile *os.File + newCrFile *os.File +} - // Create testdata. +func (rm *resourceManager) createConfigAndResourceFiles(t *testing.T) { crConfigFile, err := os.CreateTemp("", "cr-config.yaml") if err != nil { t.Fatal(err) } + rm.crConfigFile = crConfigFile + initCrdFile, err := os.CreateTemp("", "crd.yaml") if err != nil { t.Fatal(err) } + rm.initCrdFile = initCrdFile + initCrFile, err := os.CreateTemp("", "cr.yaml") if err != nil { t.Fatal(err) } + rm.initCrFile = initCrFile + newCrdFile, err := os.CreateTemp("", "new-crd.yaml") if err != nil { t.Fatal(err) } + rm.newCrdFile = newCrdFile + newCrFile, err := os.CreateTemp("", "new-cr.yaml") if err != nil { t.Fatal(err) } + rm.newCrFile = newCrFile klog.InfoS("testdata", "crConfigFile", crConfigFile.Name(), "initCrdFile", initCrdFile.Name(), "initCrFile", initCrFile.Name(), "newCrdFile", newCrdFile.Name(), "newCrFile", newCrFile.Name()) +} + +func (rm *resourceManager) removeResourceFiles(t *testing.T) { + err := os.Remove(rm.crConfigFile.Name()) + if err != nil { + t.Fatalf("failed to remove CR config: %v", err) + } + err = os.Remove(rm.initCrdFile.Name()) + if err != nil { + t.Fatalf("failed to remove initial CRD manifest: %v", err) + } + err = os.Remove(rm.initCrFile.Name()) + if err != nil { + t.Fatalf("failed to remove initial CR manifest: %v", err) + } + err = os.Remove(rm.newCrdFile.Name()) + if err != nil { + t.Fatalf("failed to remove new CRD manifest: %v", err) + } + err = os.Remove(rm.newCrFile.Name()) + if err != nil { + t.Fatalf("failed to remove new CR manifest: %v", err) + } + klog.InfoS("deleted artefacts", "crConfigFile", rm.crConfigFile.Name(), "initCrdFile", rm.initCrdFile.Name(), "initCrFile", rm.initCrFile.Name(), "newCrdFile", rm.newCrdFile.Name(), "newCrFile", rm.newCrFile.Name()) +} + +func (rm *resourceManager) writeConfigFile(t *testing.T) { + crConfig := getCRConfig() + configFile := rm.crConfigFile.Name() + err := os.WriteFile(configFile, []byte(crConfig), 0600 /* rw------- */) + if err != nil { + t.Fatalf("cannot write to config file: %v", err) + } + klog.InfoS("populated cr config file", "crConfigFile", configFile) +} + +func (rm *resourceManager) writeResourceFiles(t *testing.T) { + initCr := getCR() + initCrd := getCRD() + + newCr := getNewCR() + newCrd := getNewCRD() + err := os.WriteFile(rm.initCrdFile.Name(), []byte(initCrd), 0600 /* rw------- */) + if err != nil { + t.Fatalf("cannot write to initial crd file: %v", err) + } + err = os.WriteFile(rm.initCrFile.Name(), []byte(initCr), 0600 /* rw------- */) + if err != nil { + t.Fatalf("cannot write to initial cr file: %v", err) + } + err = os.WriteFile(rm.newCrdFile.Name(), []byte(newCrd), 0600 /* rw------- */) + if err != nil { + t.Fatalf("cannot write to new crd file: %v", err) + } + err = os.WriteFile(rm.newCrFile.Name(), []byte(newCr), 0600 /* rw------- */) + if err != nil { + t.Fatalf("cannot write to new cr file: %v", err) + } + klog.InfoS("created initial and new CR and CRD manifests") +} + +func TestVariableVKsDiscoveryAndResolution(t *testing.T) { + rm := &resourceManager{} + // Create testdata. + rm.createConfigAndResourceFiles(t) + + // Initialise options. + opts := options.NewOptions() + cmd := options.InitCommand + opts.AddFlags(cmd) + klog.InfoS("options", "options", opts) // Delete artefacts. - defer func() { - err := os.Remove(crConfigFile.Name()) - if err != nil { - t.Fatalf("failed to remove CR config: %v", err) - } - err = os.Remove(initCrdFile.Name()) - if err != nil { - t.Fatalf("failed to remove initial CRD manifest: %v", err) - } - err = os.Remove(initCrFile.Name()) - if err != nil { - t.Fatalf("failed to remove initial CR manifest: %v", err) - } - err = os.Remove(newCrdFile.Name()) - if err != nil { - t.Fatalf("failed to remove new CRD manifest: %v", err) - } - err = os.Remove(newCrFile.Name()) - if err != nil { - t.Fatalf("failed to remove new CR manifest: %v", err) - } - klog.InfoS("deleted artefacts", "crConfigFile", crConfigFile.Name(), "initCrdFile", initCrdFile.Name(), "initCrFile", initCrFile.Name(), "newCrdFile", newCrdFile.Name(), "newCrFile", newCrFile.Name()) - }() + defer rm.removeResourceFiles(t) // Populate options, and parse them. - opts.CustomResourceConfigFile = crConfigFile.Name() + opts.CustomResourceConfigFile = rm.crConfigFile.Name() opts.Kubeconfig = os.Getenv("HOME") + "/.kube/config" if err := opts.Parse(); err != nil { t.Fatalf("failed to parse options: %v", err) @@ -101,19 +159,14 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) { klog.InfoS("parsed options", "options", opts) // Write to the config file. - crConfig := getCRConfig() - err = os.WriteFile(opts.CustomResourceConfigFile, []byte(crConfig), 0600 /* rw------- */) - if err != nil { - t.Fatalf("cannot write to config file: %v", err) - } - klog.InfoS("populated cr config file", "crConfigFile", opts.CustomResourceConfigFile) + rm.writeConfigFile(t) // Make the process asynchronous. go internal.RunKubeStateMetricsWrapper(opts) klog.InfoS("started KSM") // Wait for port 8080 to come up. - err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(_ context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 20*time.Second, true, func(_ context.Context) (bool, error) { conn, err := net.Dial("tcp", "localhost:8080") if err != nil { return false, nil @@ -130,35 +183,14 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) { klog.InfoS("port 8080 up") // Create CRD and CR files. - initCr := getCR() - initCrd := getCRD() - - newCr := getNewCR() - newCrd := getNewCRD() - err = os.WriteFile(initCrdFile.Name(), []byte(initCrd), 0600 /* rw------- */) - if err != nil { - t.Fatalf("cannot write to initial crd file: %v", err) - } - err = os.WriteFile(initCrFile.Name(), []byte(initCr), 0600 /* rw------- */) - if err != nil { - t.Fatalf("cannot write to initial cr file: %v", err) - } - err = os.WriteFile(newCrdFile.Name(), []byte(newCrd), 0600 /* rw------- */) - if err != nil { - t.Fatalf("cannot write to new crd file: %v", err) - } - err = os.WriteFile(newCrFile.Name(), []byte(newCr), 0600 /* rw------- */) - if err != nil { - t.Fatalf("cannot write to new cr file: %v", err) - } - klog.InfoS("created initial and new CR and CRD manifests") + rm.writeResourceFiles(t) // Apply initial CRD and CR to the cluster. - err = exec.Command("kubectl", "apply", "-f", initCrdFile.Name()).Run() //nolint:gosec + err = exec.Command("kubectl", "apply", "-f", rm.initCrdFile.Name()).Run() //nolint:gosec if err != nil { t.Fatalf("failed to apply initial crd: %v", err) } - err = exec.Command("kubectl", "apply", "-f", initCrFile.Name()).Run() //nolint:gosec + err = exec.Command("kubectl", "apply", "-f", rm.initCrFile.Name()).Run() //nolint:gosec if err != nil { t.Fatalf("failed to apply initial cr: %v", err) } @@ -198,11 +230,11 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) { } // Apply new CRD and CR to the cluster. - err = exec.Command("kubectl", "apply", "-f", newCrdFile.Name()).Run() //nolint:gosec + err = exec.Command("kubectl", "apply", "-f", rm.newCrdFile.Name()).Run() //nolint:gosec if err != nil { t.Fatalf("failed to apply new crd: %v", err) } - err = exec.Command("kubectl", "apply", "-f", newCrFile.Name()).Run() //nolint:gosec + err = exec.Command("kubectl", "apply", "-f", rm.newCrFile.Name()).Run() //nolint:gosec if err != nil { t.Fatalf("failed to apply new cr: %v", err) } From ba9eb94f510ec50b75384e993f146b10929f0f86 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Tue, 24 Sep 2024 18:27:24 -0400 Subject: [PATCH 103/154] chore: Fix the security issue about sirupsen/logrus --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 1d5917990b..f4f99e1095 100644 --- a/go.mod +++ b/go.mod @@ -74,7 +74,7 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect diff --git a/go.sum b/go.sum index 3a639ffb4a..b5e87f5d7a 100644 --- a/go.sum +++ b/go.sum @@ -144,8 +144,8 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -162,8 +162,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -202,8 +202,8 @@ golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= From 3e2d1e9d9a53593a9fe0c57d8a6dace5087b2242 Mon Sep 17 00:00:00 2001 From: Renato Arruda Date: Wed, 18 Sep 2024 11:41:04 +0200 Subject: [PATCH 104/154] perf: use concurrent map when storing metrics In busy/large clusters, will prevent timeouts from long living locks/concurrency issues, as the writing to the map takes overly long, blocking the metrics-reading thread and as the lock doesn't get released in a timely manner, timing out the request. Inpired by previous PR at https://github.com/kubernetes/kube-state-metrics/pull/1028 --- pkg/metrics_store/metrics_store.go | 23 +++++----------------- pkg/metrics_store/metrics_writer.go | 30 ++++++++++++++++------------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/pkg/metrics_store/metrics_store.go b/pkg/metrics_store/metrics_store.go index 0339101b5b..2e6831be3a 100644 --- a/pkg/metrics_store/metrics_store.go +++ b/pkg/metrics_store/metrics_store.go @@ -20,8 +20,6 @@ import ( "sync" "k8s.io/apimachinery/pkg/api/meta" - "k8s.io/apimachinery/pkg/types" - "k8s.io/kube-state-metrics/v2/pkg/metric" ) @@ -33,7 +31,7 @@ type MetricsStore struct { // metric families, containing a slice of metrics. We need to keep metrics // grouped by metric families in order to zip families with their help text in // MetricsStore.WriteAll(). - metrics map[types.UID][][]byte + metrics sync.Map // generateMetricsFunc generates metrics based on a given Kubernetes object // and returns them grouped by metric family. @@ -42,9 +40,6 @@ type MetricsStore struct { // later on zipped with with their corresponding metric families in // MetricStore.WriteAll(). headers []string - - // Protects metrics - mutex sync.RWMutex } // NewMetricsStore returns a new MetricsStore @@ -52,7 +47,7 @@ func NewMetricsStore(headers []string, generateFunc func(interface{}) []metric.F return &MetricsStore{ generateMetricsFunc: generateFunc, headers: headers, - metrics: map[types.UID][][]byte{}, + metrics: sync.Map{}, } } @@ -66,9 +61,6 @@ func (s *MetricsStore) Add(obj interface{}) error { return err } - s.mutex.Lock() - defer s.mutex.Unlock() - families := s.generateMetricsFunc(obj) familyStrings := make([][]byte, len(families)) @@ -76,7 +68,7 @@ func (s *MetricsStore) Add(obj interface{}) error { familyStrings[i] = f.ByteSlice() } - s.metrics[o.GetUID()] = familyStrings + s.metrics.Store(o.GetUID(), familyStrings) return nil } @@ -95,10 +87,7 @@ func (s *MetricsStore) Delete(obj interface{}) error { return err } - s.mutex.Lock() - defer s.mutex.Unlock() - - delete(s.metrics, o.GetUID()) + s.metrics.Delete(o.GetUID()) return nil } @@ -126,9 +115,7 @@ func (s *MetricsStore) GetByKey(_ string) (item interface{}, exists bool, err er // Replace will delete the contents of the store, using instead the // given list. func (s *MetricsStore) Replace(list []interface{}, _ string) error { - s.mutex.Lock() - s.metrics = map[types.UID][][]byte{} - s.mutex.Unlock() + s.metrics.Clear() for _, o := range list { err := s.Add(o) diff --git a/pkg/metrics_store/metrics_writer.go b/pkg/metrics_store/metrics_writer.go index 0e263e4654..05f2196dc4 100644 --- a/pkg/metrics_store/metrics_writer.go +++ b/pkg/metrics_store/metrics_writer.go @@ -56,31 +56,35 @@ func (m MetricsWriter) WriteAll(w io.Writer) error { return nil } - for _, s := range m.stores { - s.mutex.RLock() - defer func(s *MetricsStore) { - s.mutex.RUnlock() - }(s) - } - for i, help := range m.stores[0].headers { if help != "" && help != "\n" { help += "\n" } - if len(m.stores[0].metrics) > 0 { - _, err := w.Write([]byte(help)) + var err error + m.stores[0].metrics.Range(func(key interface{}, value interface{}) bool { + _, err = w.Write([]byte(help)) if err != nil { - return fmt.Errorf("failed to write help text: %v", err) + err = fmt.Errorf("failed to write help text: %v", err) } + return false + }) + if err != nil { + return err } for _, s := range m.stores { - for _, metricFamilies := range s.metrics { - _, err := w.Write(metricFamilies[i]) + s.metrics.Range(func(key interface{}, value interface{}) bool { + metricFamilies := value.([][]byte) + _, err = w.Write(metricFamilies[i]) if err != nil { - return fmt.Errorf("failed to write metrics family: %v", err) + err = fmt.Errorf("failed to write metrics family: %v", err) + return false } + return true + }) + if err != nil { + return err } } } From f2a76390e1fa7fee7b064d9a490f83284ceeec57 Mon Sep 17 00:00:00 2001 From: Renato Arruda Date: Thu, 26 Sep 2024 14:02:08 +0200 Subject: [PATCH 105/154] lint --- pkg/metrics_store/metrics_store.go | 1 + pkg/metrics_store/metrics_writer.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/metrics_store/metrics_store.go b/pkg/metrics_store/metrics_store.go index 2e6831be3a..d0be4bdfff 100644 --- a/pkg/metrics_store/metrics_store.go +++ b/pkg/metrics_store/metrics_store.go @@ -20,6 +20,7 @@ import ( "sync" "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/kube-state-metrics/v2/pkg/metric" ) diff --git a/pkg/metrics_store/metrics_writer.go b/pkg/metrics_store/metrics_writer.go index 05f2196dc4..1deec87113 100644 --- a/pkg/metrics_store/metrics_writer.go +++ b/pkg/metrics_store/metrics_writer.go @@ -62,7 +62,7 @@ func (m MetricsWriter) WriteAll(w io.Writer) error { } var err error - m.stores[0].metrics.Range(func(key interface{}, value interface{}) bool { + m.stores[0].metrics.Range(func(_ interface{}, _ interface{}) bool { _, err = w.Write([]byte(help)) if err != nil { err = fmt.Errorf("failed to write help text: %v", err) @@ -74,7 +74,7 @@ func (m MetricsWriter) WriteAll(w io.Writer) error { } for _, s := range m.stores { - s.metrics.Range(func(key interface{}, value interface{}) bool { + s.metrics.Range(func(_ interface{}, value interface{}) bool { metricFamilies := value.([][]byte) _, err = w.Write(metricFamilies[i]) if err != nil { From ecbb9108419eaebda5240c976ade5dd964594c31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 09:55:48 +0000 Subject: [PATCH 106/154] build(deps): Bump actions/checkout from 4.1.7 to 4.2.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/692973e3d937129bcbf40652eb9f2f61becf3332...d632683dd7b4114ad314bca15554477dd762a938) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 18 +++++++++--------- .github/workflows/govulncheck.yml | 2 +- .github/workflows/openvex.yml | 2 +- .github/workflows/sbom.yaml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed8a49aff4..c7c2caf546 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -72,7 +72,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -93,7 +93,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -114,7 +114,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -135,7 +135,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup promtool run: | @@ -150,7 +150,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -171,7 +171,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -192,7 +192,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 5ed80784e4..f620a677ad 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -15,7 +15,7 @@ jobs: ci-security-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 name: Checkout code - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index 5b80fa92b2..7929aae322 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set environment variables run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index ec30c377b6..8f2b004775 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -21,7 +21,7 @@ jobs: steps: - name: Fetch source code into GITHUB_WORKSPACE - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install Kubernetes BOM uses: kubernetes-sigs/release-actions/setup-bom@2f8b9ec22aedc9ce15039b6c7716aa6c2907df1c # v0.2.0 From 7b375e9ef4324b5a64c8ad679581c6034b8af0be Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Mon, 30 Sep 2024 09:21:42 -0700 Subject: [PATCH 107/154] undo changes in internal/store/builder.go --- internal/store/builder.go | 20 ++++++-------------- tests/e2e/discovery_test.go | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/internal/store/builder.go b/internal/store/builder.go index 27f43ab3c3..f7941794e4 100644 --- a/internal/store/builder.go +++ b/internal/store/builder.go @@ -107,26 +107,18 @@ func (b *Builder) WithMetrics(r prometheus.Registerer) { // WithEnabledResources sets the enabledResources property of a Builder. func (b *Builder) WithEnabledResources(r []string) error { - enabledResources := map[string]bool{} - for _, er := range b.enabledResources { - enabledResources[er] = true - } - var newResources []string for _, resource := range r { - // validate that the resource exists and skip those that are already enabled if !resourceExists(resource) { return fmt.Errorf("resource %s does not exist. Available resources: %s", resource, strings.Join(availableResources(), ",")) } - if _, ok := enabledResources[resource]; !ok { - newResources = append(newResources, resource) - } - } - if len(newResources) == 0 { - return nil } - b.enabledResources = append(b.enabledResources, newResources...) - sort.Strings(b.enabledResources) + var sortedResources []string + sortedResources = append(sortedResources, r...) + + sort.Strings(sortedResources) + + b.enabledResources = append(b.enabledResources, sortedResources...) return nil } diff --git a/tests/e2e/discovery_test.go b/tests/e2e/discovery_test.go index 06c0ba9ccf..91a1e2a8f7 100644 --- a/tests/e2e/discovery_test.go +++ b/tests/e2e/discovery_test.go @@ -259,7 +259,7 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) { // Note: we use count to make sure that only one metrics handler is running, and we also want to validate that the // new metric is available and the old one was removed, otherwise, the response could come from the // previous handler before its context was cancelled, or maybe because it failed to be cancelled. - if strings.Count(string(out), testUpdateCRDMetric) == 1 && !strings.Contains(string(out), testMetric) { + if strings.Contains(string(out), testUpdateCRDMetric) && !strings.Contains(string(out), testMetric) { klog.InfoS("metrics available", "metric", string(out)) // Signal the process to exit, since we know the metrics are being generated as expected. ch <- true From 166921b797100dadf51a153c8b932aab73dab4ff Mon Sep 17 00:00:00 2001 From: Walther Lee Date: Mon, 30 Sep 2024 10:46:42 -0700 Subject: [PATCH 108/154] fix typo in comments --- pkg/metricshandler/metrics_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/metricshandler/metrics_handler.go b/pkg/metricshandler/metrics_handler.go index 76d83f0ccf..0a68914736 100644 --- a/pkg/metricshandler/metrics_handler.go +++ b/pkg/metricshandler/metrics_handler.go @@ -70,7 +70,7 @@ func New(opts *options.Options, kubeClient kubernetes.Interface, storeBuilder ks } // BuildWriters builds the metrics writers, cancelling any previous context and passing a new one on every build. -// Build can be used mutlitple times and concurrently. +// Build can be used multiple times and concurrently. func (m *MetricsHandler) BuildWriters(ctx context.Context) { m.mtx.Lock() defer m.mtx.Unlock() @@ -83,7 +83,7 @@ func (m *MetricsHandler) BuildWriters(ctx context.Context) { m.metricsWriters = m.storeBuilder.Build() } -// ConfigureSharding configures sharding. Configuration can be used mutlitple times and +// ConfigureSharding configures sharding. Configuration can be used multiple times and // concurrently. func (m *MetricsHandler) ConfigureSharding(ctx context.Context, shard int32, totalShards int) { m.mtx.Lock() From de58db2ed4399066caab971f8840d6ae88afa4cf Mon Sep 17 00:00:00 2001 From: Chris Bartlett Date: Tue, 1 Oct 2024 13:35:32 -0600 Subject: [PATCH 109/154] restructure testing logic Co-authored-by: Pranshu Srivastava --- internal/store/builder_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/store/builder_test.go b/internal/store/builder_test.go index 323e5b76c3..014884f9c0 100644 --- a/internal/store/builder_test.go +++ b/internal/store/builder_test.go @@ -238,13 +238,21 @@ func TestWithEnabledResources(t *testing.T) { // Set the enabled resources. err := b.WithEnabledResources(test.EnabledResources) - if err != nil && !test.err.expectedResourceError { - t.Log("Did not expect error while setting resources (--resources).") - t.Errorf("Test error for Desc: %s. Got Error: %v", test.Desc, err) + if test.err.expectedResourceError { + if err == nil { + t.Log("Did not expect error while setting resources (--resources).") + t.Fatal("Test error for Desc: %s. Got Error: %v", test.Desc, err) + } else { + return + } + } + if err != nil { + t.Log("...") + t.Fatal("...", test.Desc, err) } // Evaluate. - if !slices.Equal(b.enabledResources, test.Wanted) && err == nil { + if !slices.Equal(b.enabledResources, test.Wanted) { t.Log("Expected enabled resources to be equal.") t.Errorf("Test error for Desc: %s\n Want: \n%+v\n Got: \n%#+v", test.Desc, test.Wanted, b.enabledResources) } From cd29fabd66fee8975ab3d3f002dcac050abab312 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 09:15:51 +0000 Subject: [PATCH 110/154] build(deps): Bump github.com/prometheus/common from 0.59.1 to 0.60.0 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.59.1 to 0.60.0. - [Release notes](https://github.com/prometheus/common/releases) - [Changelog](https://github.com/prometheus/common/blob/main/RELEASE.md) - [Commits](https://github.com/prometheus/common/compare/v0.59.1...v0.60.0) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 14 +++++++------- go.sum | 28 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index b1f21ad34f..2d462280a2 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.20.4 github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common v0.59.1 + github.com/prometheus/common v0.60.0 github.com/prometheus/exporter-toolkit v0.13.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.1 @@ -80,14 +80,14 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect github.com/x448/float16 v0.8.4 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.26.0 // indirect + golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.23.0 // indirect - golang.org/x/term v0.23.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.24.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect diff --git a/go.sum b/go.sum index 10628ecf51..85ef435a9b 100644 --- a/go.sum +++ b/go.sum @@ -126,8 +126,8 @@ github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zI github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= -github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= +github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA= +github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/exporter-toolkit v0.13.0 h1:lmA0Q+8IaXgmFRKw09RldZmZdnvu9wwcDLIXGmTPw1c= github.com/prometheus/exporter-toolkit v0.13.0/go.mod h1:2uop99EZl80KdXhv/MxVI2181fMcwlsumFOqBecGkG0= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= @@ -180,8 +180,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -190,10 +190,10 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= -golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -203,14 +203,14 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 4356a0f66e333153bceebb6d521fa5f26679fc74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 09:28:56 +0000 Subject: [PATCH 111/154] build(deps): Bump actions/checkout from 4.2.0 to 4.2.1 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.0 to 4.2.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/d632683dd7b4114ad314bca15554477dd762a938...eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 18 +++++++++--------- .github/workflows/govulncheck.yml | 2 +- .github/workflows/openvex.yml | 2 +- .github/workflows/sbom.yaml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7c2caf546..1731ffdc4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -72,7 +72,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -93,7 +93,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -114,7 +114,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -135,7 +135,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Setup promtool run: | @@ -150,7 +150,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -171,7 +171,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -192,7 +192,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index f620a677ad..6c103b235b 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -15,7 +15,7 @@ jobs: ci-security-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 name: Checkout code - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index 7929aae322..a49de2ebe0 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Set environment variables run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index 8f2b004775..f0f4c90509 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -21,7 +21,7 @@ jobs: steps: - name: Fetch source code into GITHUB_WORKSPACE - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Install Kubernetes BOM uses: kubernetes-sigs/release-actions/setup-bom@2f8b9ec22aedc9ce15039b6c7716aa6c2907df1c # v0.2.0 From bd6beed33b12a7a4ead81b3106a54784273c0c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Tue, 15 Oct 2024 09:52:29 +0200 Subject: [PATCH 112/154] Update internal/store/builder_test.go --- internal/store/builder_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/store/builder_test.go b/internal/store/builder_test.go index 014884f9c0..d9ea5813e8 100644 --- a/internal/store/builder_test.go +++ b/internal/store/builder_test.go @@ -241,7 +241,7 @@ func TestWithEnabledResources(t *testing.T) { if test.err.expectedResourceError { if err == nil { t.Log("Did not expect error while setting resources (--resources).") - t.Fatal("Test error for Desc: %s. Got Error: %v", test.Desc, err) + t.Fatalf("Test error for Desc: %s. Got Error: %v", test.Desc, err) } else { return } From 90e7e1178cdff5aa7a80df2aafc2f24f5985cb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Tue, 15 Oct 2024 23:18:19 +0200 Subject: [PATCH 113/154] fix: update govulncheck's go version to 1.23 --- .github/workflows/govulncheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index f620a677ad..de83ad6670 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -6,7 +6,7 @@ on: - cron: '0 0 * * 1' env: - GO_VERSION: "^1.22" + GO_VERSION: "^1.23" permissions: contents: read From d7f7bd5297d54c4b943037e603d481ae50bdcbb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Tue, 15 Oct 2024 23:20:19 +0200 Subject: [PATCH 114/154] fix: Add missed go 1.23 updates --- Dockerfile | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c6b5e6ef65..86bc73fe5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG GOVERSION=1.22 +ARG GOVERSION=1.23 ARG GOARCH FROM golang:${GOVERSION} as builder ARG GOARCH diff --git a/Makefile b/Makefile index 5a2d9889fb..003868c7dd 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ OS ?= $(shell uname -s | tr A-Z a-z) ALL_ARCH = amd64 arm arm64 ppc64le s390x PKG = github.com/prometheus/common PROMETHEUS_VERSION = 2.54.1 -GO_VERSION = 1.23.1 +GO_VERSION = 1.23.2 IMAGE = $(REGISTRY)/kube-state-metrics MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) USER ?= $(shell id -u -n) From 28129e4d6d79aecac64985c8f1368e13fbb3078c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 16 Oct 2024 09:33:30 +0200 Subject: [PATCH 115/154] chore: Remove deprecated endpoint address metric This was deprecated in 2022 in https://github.com/kubernetes/kube-state-metrics/pull/1761 --- docs/metrics/service/endpoint-metrics.md | 2 -- internal/store/endpoint.go | 41 ------------------------ internal/store/endpoint_test.go | 16 --------- 3 files changed, 59 deletions(-) diff --git a/docs/metrics/service/endpoint-metrics.md b/docs/metrics/service/endpoint-metrics.md index 4845988bdd..6cf0823f3a 100644 --- a/docs/metrics/service/endpoint-metrics.md +++ b/docs/metrics/service/endpoint-metrics.md @@ -3,8 +3,6 @@ | Metric name | Metric type | Description | Labels/tags | Status | | ------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | | kube_endpoint_annotations | Gauge | Kubernetes annotations converted to Prometheus labels controlled via [--metric-annotations-allowlist](../../developer/cli-arguments.md) | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`annotation_ENDPOINT_ANNOTATION`=<ENDPOINT_ANNOTATION> | EXPERIMENTAL | -| kube_endpoint_address_not_ready | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | DEPRECATED | -| kube_endpoint_address_available | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | DEPRECATED | | kube_endpoint_info | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | STABLE | | kube_endpoint_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`label_ENDPOINT_LABEL`=<ENDPOINT_LABEL> | STABLE | | kube_endpoint_created | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | STABLE | diff --git a/internal/store/endpoint.go b/internal/store/endpoint.go index 482eb98e2c..5694cdfc19 100644 --- a/internal/store/endpoint.go +++ b/internal/store/endpoint.go @@ -123,47 +123,6 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge } }), ), - *generator.NewFamilyGeneratorWithStability( - "kube_endpoint_address_available", - "Number of addresses available in endpoint.", - metric.Gauge, - basemetrics.ALPHA, - "v2.6.0", - wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { - var available int - for _, s := range e.Subsets { - available += len(s.Addresses) * len(s.Ports) - } - - return &metric.Family{ - Metrics: []*metric.Metric{ - { - Value: float64(available), - }, - }, - } - }), - ), - *generator.NewFamilyGeneratorWithStability( - "kube_endpoint_address_not_ready", - "Number of addresses not ready in endpoint", - metric.Gauge, - basemetrics.ALPHA, - "v2.6.0", - wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { - var notReady int - for _, s := range e.Subsets { - notReady += len(s.NotReadyAddresses) * len(s.Ports) - } - return &metric.Family{ - Metrics: []*metric.Metric{ - { - Value: float64(notReady), - }, - }, - } - }), - ), *generator.NewFamilyGeneratorWithStability( "kube_endpoint_address", "Information about Endpoint available and non available addresses.", diff --git a/internal/store/endpoint_test.go b/internal/store/endpoint_test.go index d090a38115..87205f4d50 100644 --- a/internal/store/endpoint_test.go +++ b/internal/store/endpoint_test.go @@ -32,10 +32,6 @@ func TestEndpointStore(t *testing.T) { const metadata = ` # HELP kube_endpoint_annotations Kubernetes annotations converted to Prometheus labels. # TYPE kube_endpoint_annotations gauge - # HELP kube_endpoint_address_available (Deprecated since v2.6.0) Number of addresses available in endpoint. - # TYPE kube_endpoint_address_available gauge - # HELP kube_endpoint_address_not_ready (Deprecated since v2.6.0) Number of addresses not ready in endpoint - # TYPE kube_endpoint_address_not_ready gauge # HELP kube_endpoint_created [STABLE] Unix creation timestamp # TYPE kube_endpoint_created gauge # HELP kube_endpoint_info [STABLE] Information about endpoint. @@ -89,8 +85,6 @@ func TestEndpointStore(t *testing.T) { }, }, Want: metadata + ` - kube_endpoint_address_available{endpoint="test-endpoint",namespace="default"} 6 - kube_endpoint_address_not_ready{endpoint="test-endpoint",namespace="default"} 6 kube_endpoint_created{endpoint="test-endpoint",namespace="default"} 1.5e+09 kube_endpoint_info{endpoint="test-endpoint",namespace="default"} 1 kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="http",port_protocol="TCP",port_number="8080"} 1 @@ -132,8 +126,6 @@ func TestEndpointStore(t *testing.T) { }, }, Want: metadata + ` - kube_endpoint_address_available{endpoint="single-port-endpoint",namespace="default"} 2 - kube_endpoint_address_not_ready{endpoint="single-port-endpoint",namespace="default"} 1 kube_endpoint_created{endpoint="single-port-endpoint",namespace="default"} 1.5e+09 kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1 kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1 @@ -156,10 +148,6 @@ func TestEndpointStoreWithLabels(t *testing.T) { // Fixed metadata on type and help text. We prepend this to every expected // output so we only have to modify a single place when doing adjustments. const metadata = ` - # HELP kube_endpoint_address_available (Deprecated since v2.6.0) Number of addresses available in endpoint. - # TYPE kube_endpoint_address_available gauge - # HELP kube_endpoint_address_not_ready (Deprecated since v2.6.0) Number of addresses not ready in endpoint - # TYPE kube_endpoint_address_not_ready gauge # HELP kube_endpoint_annotations Kubernetes annotations converted to Prometheus labels. # TYPE kube_endpoint_annotations gauge # HELP kube_endpoint_created [STABLE] Unix creation timestamp @@ -218,8 +206,6 @@ func TestEndpointStoreWithLabels(t *testing.T) { }, }, Want: metadata + ` - kube_endpoint_address_available{endpoint="test-endpoint",namespace="default"} 6 - kube_endpoint_address_not_ready{endpoint="test-endpoint",namespace="default"} 6 kube_endpoint_annotations{endpoint="test-endpoint",annotation_app="foobar",namespace="default"} 1 kube_endpoint_created{endpoint="test-endpoint",namespace="default"} 1.5e+09 kube_endpoint_info{endpoint="test-endpoint",namespace="default"} 1 @@ -267,8 +253,6 @@ func TestEndpointStoreWithLabels(t *testing.T) { }, Want: metadata + ` kube_endpoint_annotations{endpoint="single-port-endpoint",annotation_app="single-foobar",namespace="default"} 1 - kube_endpoint_address_available{endpoint="single-port-endpoint",namespace="default"} 2 - kube_endpoint_address_not_ready{endpoint="single-port-endpoint",namespace="default"} 1 kube_endpoint_created{endpoint="single-port-endpoint",namespace="default"} 1.5e+09 kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1 kube_endpoint_labels{endpoint="single-port-endpoint",label_app="single-foobar",namespace="default"} 1 From ea7034553f72c8e0d2caf0cc2433ab82487f4702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Sun, 22 Sep 2024 22:55:16 +0200 Subject: [PATCH 116/154] feat(endpoints): Move ports into address metric This marks kube_endpoint_ports as deprecated --- docs/metrics/service/endpoint-metrics.md | 4 +- internal/store/endpoint.go | 46 ++++++++++++++------- internal/store/endpoint_test.go | 52 +++++++++++++++--------- 3 files changed, 66 insertions(+), 36 deletions(-) diff --git a/docs/metrics/service/endpoint-metrics.md b/docs/metrics/service/endpoint-metrics.md index 6cf0823f3a..da4152d9c3 100644 --- a/docs/metrics/service/endpoint-metrics.md +++ b/docs/metrics/service/endpoint-metrics.md @@ -6,5 +6,5 @@ | kube_endpoint_info | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | STABLE | | kube_endpoint_labels | Gauge | Kubernetes labels converted to Prometheus labels controlled via [--metric-labels-allowlist](../../developer/cli-arguments.md) | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`label_ENDPOINT_LABEL`=<ENDPOINT_LABEL> | STABLE | | kube_endpoint_created | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace> | STABLE | -| kube_endpoint_ports | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`port_name`=<endpoint-port-name>
`port_protocol`=<endpoint-port-protocol>
`port_number`=<endpoint-port-number> | STABLE | -| kube_endpoint_address | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`ip`=<endpoint-ip>
`ready`=<true if available, false if unavailalbe> | STABLE | +| kube_endpoint_ports | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`port_name`=<endpoint-port-name>
`port_protocol`=<endpoint-port-protocol>
`port_number`=<endpoint-port-number> | STABLE (Deprecated from 2.14.0) | +| kube_endpoint_address | Gauge | | `endpoint`=<endpoint-name>
`namespace`=<endpoint-namespace>
`ip`=<endpoint-ip>
`port_name`=<endpoint-port-name>
`port_protocol`=<endpoint-port-protocol>
`port_number`=<endpoint-port-number>`ready`=<true if available, false if unavailalbe> | STABLE | diff --git a/internal/store/endpoint.go b/internal/store/endpoint.go index 5694cdfc19..bdb8f43f7b 100644 --- a/internal/store/endpoint.go +++ b/internal/store/endpoint.go @@ -132,19 +132,37 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { ms := []*metric.Metric{} for _, s := range e.Subsets { - for _, available := range s.Addresses { - ms = append(ms, &metric.Metric{ - LabelValues: []string{available.IP, "true"}, - LabelKeys: []string{"ip", "ready"}, - Value: 1, - }) - } - for _, notReadyAddresses := range s.NotReadyAddresses { - ms = append(ms, &metric.Metric{ - LabelValues: []string{notReadyAddresses.IP, "false"}, - LabelKeys: []string{"ip", "ready"}, - Value: 1, - }) + for _, port := range s.Ports { + for _, available := range s.Addresses { + labelValues := []string{string(port.Protocol), strconv.FormatInt(int64(port.Port), 10)} + labelKeys := []string{"port_protocol", "port_number"} + + if port.Name != "" { + labelKeys = append(labelKeys, "port_name") + labelValues = append(labelValues, port.Name) + } + + ms = append(ms, &metric.Metric{ + LabelValues: append(labelValues, available.IP, "true"), + LabelKeys: append(labelKeys, "ip", "ready"), + Value: 1, + }) + } + for _, notReadyAddresses := range s.NotReadyAddresses { + labelValues := []string{string(port.Protocol), strconv.FormatInt(int64(port.Port), 10)} + labelKeys := []string{"port_protocol", "port_number"} + + if port.Name != "" { + labelKeys = append(labelKeys, "port_name") + labelValues = append(labelValues, port.Name) + } + + ms = append(ms, &metric.Metric{ + LabelValues: append(labelValues, notReadyAddresses.IP, "false"), + LabelKeys: append(labelKeys, "ip", "ready"), + Value: 1, + }) + } } } return &metric.Family{ @@ -157,7 +175,7 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge "Information about the Endpoint ports.", metric.Gauge, basemetrics.STABLE, - "", + "v2.14.0", wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { ms := []*metric.Metric{} for _, s := range e.Subsets { diff --git a/internal/store/endpoint_test.go b/internal/store/endpoint_test.go index 87205f4d50..984b13e726 100644 --- a/internal/store/endpoint_test.go +++ b/internal/store/endpoint_test.go @@ -38,7 +38,7 @@ func TestEndpointStore(t *testing.T) { # TYPE kube_endpoint_info gauge # HELP kube_endpoint_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_endpoint_labels gauge - # HELP kube_endpoint_ports [STABLE] Information about the Endpoint ports. + # HELP kube_endpoint_ports [STABLE] (Deprecated since v2.14.0) Information about the Endpoint ports. # TYPE kube_endpoint_ports gauge # HELP kube_endpoint_address [STABLE] Information about Endpoint available and non available addresses. # TYPE kube_endpoint_address gauge @@ -87,18 +87,24 @@ func TestEndpointStore(t *testing.T) { Want: metadata + ` kube_endpoint_created{endpoint="test-endpoint",namespace="default"} 1.5e+09 kube_endpoint_info{endpoint="test-endpoint",namespace="default"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.1",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.1",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.10",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.10",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="127.0.0.1",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="127.0.0.1",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="172.22.23.202",namespace="default",port_name="https",port_number="8443",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="172.22.23.202",namespace="default",port_name="prometheus",port_number="9090",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="192.168.1.3",namespace="default",port_name="syslog",port_number="1234",port_protocol="UDP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="192.168.1.3",namespace="default",port_name="syslog-tcp",port_number="5678",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="192.168.2.2",namespace="default",port_name="syslog",port_number="1234",port_protocol="UDP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="192.168.2.2",namespace="default",port_name="syslog-tcp",port_number="5678",port_protocol="TCP",ready="false"} 1 kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="http",port_protocol="TCP",port_number="8080"} 1 kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="app",port_protocol="TCP",port_number="8081"} 1 kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="https",port_protocol="TCP",port_number="8443"} 1 kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="prometheus",port_protocol="TCP",port_number="9090"} 1 kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog",port_protocol="UDP",port_number="1234"} 1 kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog-tcp",port_protocol="TCP",port_number="5678"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="127.0.0.1",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="10.0.0.1",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="172.22.23.202",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="192.168.1.3",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="192.168.2.2",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="10.0.0.10",ready="false"} 1 `, }, { @@ -129,9 +135,9 @@ func TestEndpointStore(t *testing.T) { kube_endpoint_created{endpoint="single-port-endpoint",namespace="default"} 1.5e+09 kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1 kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",ip="127.0.0.1",ready="true"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",ip="10.0.0.1",ready="true"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",ip="10.0.0.10",ready="false"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.1",namespace="default",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.10",namespace="default",port_number="8080",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="127.0.0.1",namespace="default",port_number="8080",port_protocol="TCP",ready="true"} 1 `, }, } @@ -156,7 +162,7 @@ func TestEndpointStoreWithLabels(t *testing.T) { # TYPE kube_endpoint_info gauge # HELP kube_endpoint_labels [STABLE] Kubernetes labels converted to Prometheus labels. # TYPE kube_endpoint_labels gauge - # HELP kube_endpoint_ports [STABLE] Information about the Endpoint ports. + # HELP kube_endpoint_ports [STABLE] (Deprecated since v2.14.0) Information about the Endpoint ports. # TYPE kube_endpoint_ports gauge # HELP kube_endpoint_address [STABLE] Information about Endpoint available and non available addresses. # TYPE kube_endpoint_address gauge @@ -216,12 +222,18 @@ func TestEndpointStoreWithLabels(t *testing.T) { kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="prometheus",port_protocol="TCP",port_number="9090"} 1 kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog",port_protocol="UDP",port_number="1234"} 1 kube_endpoint_ports{endpoint="test-endpoint",namespace="default",port_name="syslog-tcp",port_protocol="TCP",port_number="5678"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="127.0.0.1",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="10.0.0.1",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="172.22.23.202",ready="true"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="192.168.1.3",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="192.168.2.2",ready="false"} 1 - kube_endpoint_address{endpoint="test-endpoint",namespace="default",ip="10.0.0.10",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.1",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.1",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.10",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="10.0.0.10",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="127.0.0.1",namespace="default",port_name="app",port_number="8081",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="127.0.0.1",namespace="default",port_name="http",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="172.22.23.202",namespace="default",port_name="https",port_number="8443",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="172.22.23.202",namespace="default",port_name="prometheus",port_number="9090",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="192.168.1.3",namespace="default",port_name="syslog",port_number="1234",port_protocol="UDP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="192.168.1.3",namespace="default",port_name="syslog-tcp",port_number="5678",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="192.168.2.2",namespace="default",port_name="syslog",port_number="1234",port_protocol="UDP",ready="false"} 1 + kube_endpoint_address{endpoint="test-endpoint",ip="192.168.2.2",namespace="default",port_name="syslog-tcp",port_number="5678",port_protocol="TCP",ready="false"} 1 `, }, { @@ -257,9 +269,9 @@ func TestEndpointStoreWithLabels(t *testing.T) { kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1 kube_endpoint_labels{endpoint="single-port-endpoint",label_app="single-foobar",namespace="default"} 1 kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",ip="127.0.0.1",ready="true"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",ip="10.0.0.1",ready="true"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",namespace="default",ip="10.0.0.10",ready="false"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.1",namespace="default",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.10",namespace="default",port_number="8080",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="127.0.0.1",namespace="default",port_number="8080",port_protocol="TCP",ready="true"} 1 `, }, } From 0a331e1a600b7a22056be0b9fc2d1c6fae811cc8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 09:12:08 +0000 Subject: [PATCH 117/154] build(deps): Bump kubernetes-sigs/release-actions from 0.2.0 to 0.3.0 Bumps [kubernetes-sigs/release-actions](https://github.com/kubernetes-sigs/release-actions) from 0.2.0 to 0.3.0. - [Release notes](https://github.com/kubernetes-sigs/release-actions/releases) - [Changelog](https://github.com/kubernetes-sigs/release-actions/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes-sigs/release-actions/compare/2f8b9ec22aedc9ce15039b6c7716aa6c2907df1c...a69972745f85aab4ba5d6c681e2a0e7f73eaff2b) --- updated-dependencies: - dependency-name: kubernetes-sigs/release-actions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/sbom.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index f0f4c90509..898fe09051 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Install Kubernetes BOM - uses: kubernetes-sigs/release-actions/setup-bom@2f8b9ec22aedc9ce15039b6c7716aa6c2907df1c # v0.2.0 + uses: kubernetes-sigs/release-actions/setup-bom@a69972745f85aab4ba5d6c681e2a0e7f73eaff2b # v0.3.0 - name: Generate SBOM run: | From f9c945aef53dab78e2841d9df1cbebb427cc273e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:03:28 +0000 Subject: [PATCH 118/154] build(deps): Bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.20.4 to 1.20.5. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.20.4...v1.20.5) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2d462280a2..ac00bd06a2 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/gobuffalo/flect v1.0.3 github.com/google/go-cmp v0.6.0 github.com/oklog/run v1.1.0 - github.com/prometheus/client_golang v1.20.4 + github.com/prometheus/client_golang v1.20.5 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.60.0 github.com/prometheus/exporter-toolkit v0.13.0 diff --git a/go.sum b/go.sum index 85ef435a9b..64765f381c 100644 --- a/go.sum +++ b/go.sum @@ -122,8 +122,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= -github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= +github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA= From f3ff773d3169b35289296cbfb3b182b5d7ea3422 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 00:03:10 +0000 Subject: [PATCH 119/154] build(deps): Bump actions/checkout from 4.2.1 to 4.2.2 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.1 to 4.2.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871...11bd71901bbe5b1630ceea73d27597364c9af683) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 18 +++++++++--------- .github/workflows/govulncheck.yml | 2 +- .github/workflows/openvex.yml | 2 +- .github/workflows/sbom.yaml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1731ffdc4a..612551ab57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -72,7 +72,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -93,7 +93,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -114,7 +114,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -135,7 +135,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Setup promtool run: | @@ -150,7 +150,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -171,7 +171,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 @@ -192,7 +192,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 851df249a6..3681db05d7 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -15,7 +15,7 @@ jobs: ci-security-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 name: Checkout code - name: Set up Go 1.x uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 diff --git a/.github/workflows/openvex.yml b/.github/workflows/openvex.yml index a49de2ebe0..3685a775fe 100644 --- a/.github/workflows/openvex.yml +++ b/.github/workflows/openvex.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set environment variables run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV diff --git a/.github/workflows/sbom.yaml b/.github/workflows/sbom.yaml index 898fe09051..a2a064a93d 100644 --- a/.github/workflows/sbom.yaml +++ b/.github/workflows/sbom.yaml @@ -21,7 +21,7 @@ jobs: steps: - name: Fetch source code into GITHUB_WORKSPACE - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Kubernetes BOM uses: kubernetes-sigs/release-actions/setup-bom@a69972745f85aab4ba5d6c681e2a0e7f73eaff2b # v0.3.0 From 2dacb29426176ec8529d808d9d1e6e93f98b8165 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 00:03:39 +0000 Subject: [PATCH 120/154] build(deps): Bump the k8s-dependencies group with 5 updates Bumps the k8s-dependencies group with 5 updates: | Package | From | To | | --- | --- | --- | | [k8s.io/api](https://github.com/kubernetes/api) | `0.31.1` | `0.31.2` | | [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) | `0.31.1` | `0.31.2` | | [k8s.io/client-go](https://github.com/kubernetes/client-go) | `0.31.1` | `0.31.2` | | [k8s.io/component-base](https://github.com/kubernetes/component-base) | `0.31.1` | `0.31.2` | | [k8s.io/sample-controller](https://github.com/kubernetes/sample-controller) | `0.31.1` | `0.31.2` | Updates `k8s.io/api` from 0.31.1 to 0.31.2 - [Commits](https://github.com/kubernetes/api/compare/v0.31.1...v0.31.2) Updates `k8s.io/apimachinery` from 0.31.1 to 0.31.2 - [Commits](https://github.com/kubernetes/apimachinery/compare/v0.31.1...v0.31.2) Updates `k8s.io/client-go` from 0.31.1 to 0.31.2 - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes/client-go/compare/v0.31.1...v0.31.2) Updates `k8s.io/component-base` from 0.31.1 to 0.31.2 - [Commits](https://github.com/kubernetes/component-base/compare/v0.31.1...v0.31.2) Updates `k8s.io/sample-controller` from 0.31.1 to 0.31.2 - [Commits](https://github.com/kubernetes/sample-controller/compare/v0.31.1...v0.31.2) --- updated-dependencies: - dependency-name: k8s.io/api dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/apimachinery dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/client-go dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/component-base dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies - dependency-name: k8s.io/sample-controller dependency-type: direct:production update-type: version-update:semver-patch dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index ac00bd06a2..8c76f48b0d 100644 --- a/go.mod +++ b/go.mod @@ -19,12 +19,12 @@ require ( github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.31.1 - k8s.io/apimachinery v0.31.1 - k8s.io/client-go v0.31.1 - k8s.io/component-base v0.31.1 + k8s.io/api v0.31.2 + k8s.io/apimachinery v0.31.2 + k8s.io/client-go v0.31.2 + k8s.io/component-base v0.31.2 k8s.io/klog/v2 v2.130.1 - k8s.io/sample-controller v0.31.1 + k8s.io/sample-controller v0.31.2 k8s.io/utils v0.0.0-20240821151609-f90d01438635 ) diff --git a/go.sum b/go.sum index 64765f381c..51cd2bb428 100644 --- a/go.sum +++ b/go.sum @@ -240,20 +240,20 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.31.1 h1:Xe1hX/fPW3PXYYv8BlozYqw63ytA92snr96zMW9gWTU= -k8s.io/api v0.31.1/go.mod h1:sbN1g6eY6XVLeqNsZGLnI5FwVseTrZX7Fv3O26rhAaI= -k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U= -k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= -k8s.io/client-go v0.31.1 h1:f0ugtWSbWpxHR7sjVpQwuvw9a3ZKLXX0u0itkFXufb0= -k8s.io/client-go v0.31.1/go.mod h1:sKI8871MJN2OyeqRlmA4W4KM9KBdBUpDLu/43eGemCg= -k8s.io/component-base v0.31.1 h1:UpOepcrX3rQ3ab5NB6g5iP0tvsgJWzxTyAo20sgYSy8= -k8s.io/component-base v0.31.1/go.mod h1:WGeaw7t/kTsqpVTaCoVEtillbqAhF2/JgvO0LDOMa0w= +k8s.io/api v0.31.2 h1:3wLBbL5Uom/8Zy98GRPXpJ254nEFpl+hwndmk9RwmL0= +k8s.io/api v0.31.2/go.mod h1:bWmGvrGPssSK1ljmLzd3pwCQ9MgoTsRCuK35u6SygUk= +k8s.io/apimachinery v0.31.2 h1:i4vUt2hPK56W6mlT7Ry+AO8eEsyxMD1U44NR22CLTYw= +k8s.io/apimachinery v0.31.2/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/client-go v0.31.2 h1:Y2F4dxU5d3AQj+ybwSMqQnpZH9F30//1ObxOKlTI9yc= +k8s.io/client-go v0.31.2/go.mod h1:NPa74jSVR/+eez2dFsEIHNa+3o09vtNaWwWwb1qSxSs= +k8s.io/component-base v0.31.2 h1:Z1J1LIaC0AV+nzcPRFqfK09af6bZ4D1nAOpWsy9owlA= +k8s.io/component-base v0.31.2/go.mod h1:9PeyyFN/drHjtJZMCTkSpQJS3U9OXORnHQqMLDz0sUQ= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= -k8s.io/sample-controller v0.31.1 h1:PTVmLuBqduC78vQLA+RZhs80OgYLXaMXeGsoSftUHRg= -k8s.io/sample-controller v0.31.1/go.mod h1:hyJVSX8dSwJOe0xhvqufFB9m/STgXhemLMc82If4WSU= +k8s.io/sample-controller v0.31.2 h1:1Nygz1ZsKA13cjz6jP3ZM5HwZap+TFx1CA07zqWuJYY= +k8s.io/sample-controller v0.31.2/go.mod h1:saA7VVGDYlpNiQ54GKXGHFEuG/R7bbSal2KWPmCiAtg= k8s.io/utils v0.0.0-20240821151609-f90d01438635 h1:2wThSvJoW/Ncn9TmQEYXRnevZXi2duqHWf5OX9S3zjI= k8s.io/utils v0.0.0-20240821151609-f90d01438635/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= From 51f854f305b3f27de2a828fd8bdbf950bfb2262a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 00:03:46 +0000 Subject: [PATCH 121/154] build(deps): Bump github.com/prometheus/common from 0.60.0 to 0.60.1 Bumps [github.com/prometheus/common](https://github.com/prometheus/common) from 0.60.0 to 0.60.1. - [Release notes](https://github.com/prometheus/common/releases) - [Changelog](https://github.com/prometheus/common/blob/main/RELEASE.md) - [Commits](https://github.com/prometheus/common/compare/v0.60.0...v0.60.1) --- updated-dependencies: - dependency-name: github.com/prometheus/common dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ac00bd06a2..016bc6b15e 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/oklog/run v1.1.0 github.com/prometheus/client_golang v1.20.5 github.com/prometheus/client_model v0.6.1 - github.com/prometheus/common v0.60.0 + github.com/prometheus/common v0.60.1 github.com/prometheus/exporter-toolkit v0.13.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.1 diff --git a/go.sum b/go.sum index 64765f381c..bb77be036a 100644 --- a/go.sum +++ b/go.sum @@ -126,8 +126,8 @@ github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+ github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA= -github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= +github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= +github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/exporter-toolkit v0.13.0 h1:lmA0Q+8IaXgmFRKw09RldZmZdnvu9wwcDLIXGmTPw1c= github.com/prometheus/exporter-toolkit v0.13.0/go.mod h1:2uop99EZl80KdXhv/MxVI2181fMcwlsumFOqBecGkG0= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= From 3b5c6240a9eb65886743259e70b632a8cff545a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 00:13:02 +0000 Subject: [PATCH 122/154] build(deps): Bump actions/setup-go from 5.0.2 to 5.1.0 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.1.0. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32...41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 16 ++++++++-------- .github/workflows/govulncheck.yml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 612551ab57..a42280f7ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ env.GO_VERSION }} id: go @@ -54,7 +54,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ env.GO_VERSION }} id: go @@ -75,7 +75,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ env.GO_VERSION }} id: go @@ -96,7 +96,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ env.GO_VERSION }} id: go @@ -117,7 +117,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ env.GO_VERSION }} id: go @@ -153,7 +153,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ env.GO_VERSION }} id: go @@ -174,7 +174,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ env.GO_VERSION }} id: go @@ -195,7 +195,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go 1.x - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ env.GO_VERSION }} id: go diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 3681db05d7..02fe175d48 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 name: Checkout code - name: Set up Go 1.x - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: go-version: ${{ env.GO_VERSION }} - name: Install govulncheck binary From 110f03d7331faddbd1950fb2a5cd7f713b775704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Thu, 24 Oct 2024 18:39:17 +0200 Subject: [PATCH 123/154] Fix a panic in GVRFromType for core objects --- pkg/util/utils.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 14b108f37e..837a0fd564 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -143,11 +143,10 @@ func GVRFromType(resourceName string, expectedType interface{}) *schema.GroupVer return nil } apiVersion := expectedType.(*unstructured.Unstructured).Object["apiVersion"].(string) - expectedTypeSlice := strings.Split(apiVersion, "/") - g := expectedTypeSlice[0] - v := expectedTypeSlice[1] - if v == "" /* "" group (core) objects */ { - v = expectedTypeSlice[0] + g, v, found := strings.Cut(apiVersion, "/") + if !found { + g = "core" + v = apiVersion } r := resourceName return &schema.GroupVersionResource{ From 17c69692c470ccc3001a622b3a1e841a8004f353 Mon Sep 17 00:00:00 2001 From: Haley Wang Date: Tue, 29 Oct 2024 13:55:05 +0800 Subject: [PATCH 124/154] fix(custom resource state metrics): corrctly convert status condition `Unknown` to a valid value --- docs/metrics/extend/customresourcestate-metrics.md | 2 +- pkg/customresourcestate/registry_factory.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/metrics/extend/customresourcestate-metrics.md b/docs/metrics/extend/customresourcestate-metrics.md index 9330478b8e..c28b04b0f8 100644 --- a/docs/metrics/extend/customresourcestate-metrics.md +++ b/docs/metrics/extend/customresourcestate-metrics.md @@ -337,7 +337,7 @@ Supported types are: * `nil` is generally mapped to `0.0` if NilIsZero is `true`, otherwise it will throw an error * for bool `true` is mapped to `1.0` and `false` is mapped to `0.0` * for string the following logic applies - * `"true"` and `"yes"` are mapped to `1.0` and `"false"` and `"no"` are mapped to `0.0` (all case-insensitive) + * `"true"` and `"yes"` are mapped to `1.0`, `"false"`, `"no"` and `"unknown"` are mapped to `0.0` (all case-insensitive) * RFC3339 times are parsed to float timestamp * Quantities like "250m" or "512Gi" are parsed to float using * Percentages ending with a "%" are parsed to float diff --git a/pkg/customresourcestate/registry_factory.go b/pkg/customresourcestate/registry_factory.go index e4413d4dc2..39c261bd2e 100644 --- a/pkg/customresourcestate/registry_factory.go +++ b/pkg/customresourcestate/registry_factory.go @@ -131,9 +131,11 @@ type compiledCommon struct { func (c compiledCommon) Path() valuePath { return c.path } + func (c compiledCommon) LabelFromPath() map[string]valuePath { return c.labelFromPath } + func (c compiledCommon) Type() metric.Type { return c.t } @@ -477,6 +479,7 @@ func (e eachValue) DefaultLabels(defaults map[string]string) { } } } + func (e eachValue) ToMetric() *metric.Metric { var keys, values []string for k := range e.Labels { @@ -732,6 +735,9 @@ func toFloat64(value interface{}, nilIsZero bool) (float64, error) { if normalized == "false" || normalized == "no" { return 0, nil } + if normalized == "unknown" { + return 0, nil + } // The string contains a RFC3339 timestamp if t, e := time.Parse(time.RFC3339, value.(string)); e == nil { return float64(t.Unix()), nil From c24e50d04234ff4a7185876253bb14e0c5234f4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:29:29 +0000 Subject: [PATCH 125/154] build(deps): Bump github.com/prometheus/exporter-toolkit Bumps [github.com/prometheus/exporter-toolkit](https://github.com/prometheus/exporter-toolkit) from 0.13.0 to 0.13.1. - [Release notes](https://github.com/prometheus/exporter-toolkit/releases) - [Changelog](https://github.com/prometheus/exporter-toolkit/blob/master/CHANGELOG.md) - [Commits](https://github.com/prometheus/exporter-toolkit/compare/v0.13.0...v0.13.1) --- updated-dependencies: - dependency-name: github.com/prometheus/exporter-toolkit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index ea1ac236e6..022f071465 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/prometheus/client_golang v1.20.5 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.60.1 - github.com/prometheus/exporter-toolkit v0.13.0 + github.com/prometheus/exporter-toolkit v0.13.1 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 @@ -80,14 +80,14 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect github.com/x448/float16 v0.8.4 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.27.0 // indirect + golang.org/x/crypto v0.28.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.29.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.25.0 // indirect - golang.org/x/term v0.24.0 // indirect - golang.org/x/text v0.18.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect diff --git a/go.sum b/go.sum index 36737244b1..c4a6064c02 100644 --- a/go.sum +++ b/go.sum @@ -128,8 +128,8 @@ github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= -github.com/prometheus/exporter-toolkit v0.13.0 h1:lmA0Q+8IaXgmFRKw09RldZmZdnvu9wwcDLIXGmTPw1c= -github.com/prometheus/exporter-toolkit v0.13.0/go.mod h1:2uop99EZl80KdXhv/MxVI2181fMcwlsumFOqBecGkG0= +github.com/prometheus/exporter-toolkit v0.13.1 h1:Evsh0gWQo2bdOHlnz9+0Nm7/OFfIwhE2Ws4A2jIlR04= +github.com/prometheus/exporter-toolkit v0.13.1/go.mod h1:ujdv2YIOxtdFxxqtloLpbqmxd5J0Le6IITUvIRSWjj0= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= @@ -180,8 +180,8 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -203,14 +203,14 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= -golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 75e7841c106fdf34635eedd995fa39889c50563a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 31 Oct 2024 12:21:51 +0100 Subject: [PATCH 126/154] endpointslices: Expose empty labels --- internal/store/endpointslice.go | 47 ++++++++++------------------ internal/store/endpointslice_test.go | 10 +++--- 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/internal/store/endpointslice.go b/internal/store/endpointslice.go index 504e548c57..6f5eeae751 100644 --- a/internal/store/endpointslice.go +++ b/internal/store/endpointslice.go @@ -121,54 +121,41 @@ func endpointSliceMetricFamilies(allowAnnotationsList, allowLabelsList []string) wrapEndpointSliceFunc(func(e *discoveryv1.EndpointSlice) *metric.Family { m := []*metric.Metric{} for _, ep := range e.Endpoints { - var ( - labelKeys, - labelValues []string - ) + + var ready, serving, terminating, hostname, targetrefKind, targetrefName, targetrefNamespace, endpointNodename, endpointZone string if ep.Conditions.Ready != nil { - labelKeys = append(labelKeys, "ready") - labelValues = append(labelValues, strconv.FormatBool(*ep.Conditions.Ready)) + ready = strconv.FormatBool(*ep.Conditions.Ready) } + if ep.Conditions.Serving != nil { - labelKeys = append(labelKeys, "serving") - labelValues = append(labelValues, strconv.FormatBool(*ep.Conditions.Serving)) + serving = strconv.FormatBool(*ep.Conditions.Serving) } + if ep.Conditions.Terminating != nil { - labelKeys = append(labelKeys, "terminating") - labelValues = append(labelValues, strconv.FormatBool(*ep.Conditions.Terminating)) + serving = strconv.FormatBool(*ep.Conditions.Terminating) } - if ep.Hostname != nil { - labelKeys = append(labelKeys, "hostname") - labelValues = append(labelValues, *ep.Hostname) + hostname = *ep.Hostname } if ep.TargetRef != nil { - if ep.TargetRef.Kind != "" { - labelKeys = append(labelKeys, "targetref_kind") - labelValues = append(labelValues, ep.TargetRef.Kind) - } - if ep.TargetRef.Name != "" { - labelKeys = append(labelKeys, "targetref_name") - labelValues = append(labelValues, ep.TargetRef.Name) - } - if ep.TargetRef.Namespace != "" { - labelKeys = append(labelKeys, "targetref_namespace") - labelValues = append(labelValues, ep.TargetRef.Namespace) - } + targetrefKind = ep.TargetRef.Kind + targetrefName = ep.TargetRef.Name + targetrefNamespace = ep.TargetRef.Namespace } if ep.NodeName != nil { - labelKeys = append(labelKeys, "endpoint_nodename") - labelValues = append(labelValues, *ep.NodeName) + endpointNodename = *ep.NodeName } if ep.Zone != nil { - labelKeys = append(labelKeys, "endpoint_zone") - labelValues = append(labelValues, *ep.Zone) + endpointZone = *ep.Zone } - labelKeys = append(labelKeys, "address") + + labelKeys := []string{"ready", "serving", "hostname", "terminating", "targetref_kind", "targetref_name", "targetref_namespace", "endpoint_nodename", "endpoint_zone", "address"} + labelValues := []string{ready, serving, terminating, hostname, targetrefKind, targetrefName, targetrefNamespace, endpointNodename, endpointZone} + for _, address := range ep.Addresses { newlabelValues := make([]string, len(labelValues)) copy(newlabelValues, labelValues) diff --git a/internal/store/endpointslice_test.go b/internal/store/endpointslice_test.go index ccd1de1f10..bdb8a94193 100644 --- a/internal/store/endpointslice_test.go +++ b/internal/store/endpointslice_test.go @@ -120,8 +120,8 @@ func TestEndpointSliceStore(t *testing.T) { # HELP kube_endpointslice_endpoints_hints Topology routing hints attached to endpoints # TYPE kube_endpointslice_endpoints gauge # TYPE kube_endpointslice_endpoints_hints gauge - kube_endpointslice_endpoints{address="10.0.0.1",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="host",ready="true",terminating="false",namespace="test"} 1 - kube_endpointslice_endpoints{address="192.168.1.10",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="host",ready="true",terminating="false",namespace="test"} 1 + kube_endpointslice_endpoints{address="10.0.0.1",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="",namespace="test",ready="true",serving="false",targetref_kind="",targetref_name="",targetref_namespace="",terminating="host"} 1 + kube_endpointslice_endpoints{address="192.168.1.10",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="",namespace="test",ready="true",serving="false",targetref_kind="",targetref_name="",targetref_namespace="",terminating="host"} 1 `, MetricNames: []string{ @@ -159,9 +159,9 @@ func TestEndpointSliceStore(t *testing.T) { # TYPE kube_endpointslice_endpoints gauge # TYPE kube_endpointslice_endpoints_hints gauge kube_endpointslice_endpoints_hints{address="10.0.0.1",endpointslice="test_endpointslice-endpoints",for_zone="zone1",namespace="test"} 1 - kube_endpointslice_endpoints{address="10.0.0.1",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="host",ready="true",terminating="false",namespace="test"} 1 - kube_endpointslice_endpoints{address="192.168.1.10",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="host",ready="true",terminating="false",namespace="test"} 1 - `, + kube_endpointslice_endpoints{address="10.0.0.1",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="",namespace="test",ready="true",serving="false",targetref_kind="",targetref_name="",targetref_namespace="",terminating="host"} 1 + kube_endpointslice_endpoints{address="192.168.1.10",endpoint_nodename="node",endpoint_zone="west",endpointslice="test_endpointslice-endpoints",hostname="",namespace="test",ready="true",serving="false",targetref_kind="",targetref_name="",targetref_namespace="",terminating="host"} 1 + `, MetricNames: []string{ "kube_endpointslice_endpoints", From 63749c5d15d909932071e53b47abf2a82e2940ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 31 Oct 2024 12:29:35 +0100 Subject: [PATCH 127/154] endpoints: Expose empty labels --- internal/store/endpoint.go | 22 ++++++---------------- internal/store/endpoint_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/internal/store/endpoint.go b/internal/store/endpoint.go index bdb8f43f7b..fddfa4fde5 100644 --- a/internal/store/endpoint.go +++ b/internal/store/endpoint.go @@ -131,35 +131,25 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge "", wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family { ms := []*metric.Metric{} + labelKeys := []string{"port_protocol", "port_number", "port_name", "ip", "ready"} + for _, s := range e.Subsets { for _, port := range s.Ports { for _, available := range s.Addresses { - labelValues := []string{string(port.Protocol), strconv.FormatInt(int64(port.Port), 10)} - labelKeys := []string{"port_protocol", "port_number"} - - if port.Name != "" { - labelKeys = append(labelKeys, "port_name") - labelValues = append(labelValues, port.Name) - } + labelValues := []string{string(port.Protocol), strconv.FormatInt(int64(port.Port), 10), port.Name} ms = append(ms, &metric.Metric{ LabelValues: append(labelValues, available.IP, "true"), - LabelKeys: append(labelKeys, "ip", "ready"), + LabelKeys: labelKeys, Value: 1, }) } for _, notReadyAddresses := range s.NotReadyAddresses { - labelValues := []string{string(port.Protocol), strconv.FormatInt(int64(port.Port), 10)} - labelKeys := []string{"port_protocol", "port_number"} - - if port.Name != "" { - labelKeys = append(labelKeys, "port_name") - labelValues = append(labelValues, port.Name) - } + labelValues := []string{string(port.Protocol), strconv.FormatInt(int64(port.Port), 10), port.Name} ms = append(ms, &metric.Metric{ LabelValues: append(labelValues, notReadyAddresses.IP, "false"), - LabelKeys: append(labelKeys, "ip", "ready"), + LabelKeys: labelKeys, Value: 1, }) } diff --git a/internal/store/endpoint_test.go b/internal/store/endpoint_test.go index 984b13e726..b38374767d 100644 --- a/internal/store/endpoint_test.go +++ b/internal/store/endpoint_test.go @@ -135,9 +135,9 @@ func TestEndpointStore(t *testing.T) { kube_endpoint_created{endpoint="single-port-endpoint",namespace="default"} 1.5e+09 kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1 kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.1",namespace="default",port_number="8080",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.10",namespace="default",port_number="8080",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="127.0.0.1",namespace="default",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.1",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.10",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="127.0.0.1",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="true"} 1 `, }, } @@ -269,9 +269,9 @@ func TestEndpointStoreWithLabels(t *testing.T) { kube_endpoint_info{endpoint="single-port-endpoint",namespace="default"} 1 kube_endpoint_labels{endpoint="single-port-endpoint",label_app="single-foobar",namespace="default"} 1 kube_endpoint_ports{endpoint="single-port-endpoint",namespace="default",port_name="",port_number="8080",port_protocol="TCP"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.1",namespace="default",port_number="8080",port_protocol="TCP",ready="true"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.10",namespace="default",port_number="8080",port_protocol="TCP",ready="false"} 1 - kube_endpoint_address{endpoint="single-port-endpoint",ip="127.0.0.1",namespace="default",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.1",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="true"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="10.0.0.10",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="false"} 1 + kube_endpoint_address{endpoint="single-port-endpoint",ip="127.0.0.1",namespace="default",port_name="",port_number="8080",port_protocol="TCP",ready="true"} 1 `, }, } From 9f15cc1c8c3c0fdd6895155ed3f3c3493332cb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 31 Oct 2024 17:40:10 +0100 Subject: [PATCH 128/154] pods: Expose empty labels --- internal/store/pod.go | 31 ++++++++----------------------- internal/store/pod_test.go | 7 ++++--- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/internal/store/pod.go b/internal/store/pod.go index 8c39017283..0f1f37ad29 100644 --- a/internal/store/pod.go +++ b/internal/store/pod.go @@ -1653,41 +1653,26 @@ func createPodTolerationsFamilyGenerator() generator.FamilyGenerator { var ms []*metric.Metric for _, t := range p.Spec.Tolerations { - var labelKeys []string - var labelValues []string - - if t.Key != "" { - labelKeys = append(labelKeys, "key") - labelValues = append(labelValues, t.Key) - } + var key, operator, value, effect, tolerationSeconds string + key = t.Key if t.Operator != "" { - labelKeys = append(labelKeys, "operator") - labelValues = append(labelValues, string(t.Operator)) + operator = string(t.Operator) } - if t.Value != "" { - labelKeys = append(labelKeys, "value") - labelValues = append(labelValues, t.Value) - } + value = t.Value if t.Effect != "" { - labelKeys = append(labelKeys, "effect") - labelValues = append(labelValues, string(t.Effect)) + effect = string(t.Effect) } if t.TolerationSeconds != nil { - labelKeys = append(labelKeys, "toleration_seconds") - labelValues = append(labelValues, strconv.FormatInt(*t.TolerationSeconds, 10)) - } - - if len(labelKeys) == 0 { - continue + tolerationSeconds = strconv.FormatInt(*t.TolerationSeconds, 10) } ms = append(ms, &metric.Metric{ - LabelKeys: labelKeys, - LabelValues: labelValues, + LabelKeys: []string{"key", "operator", "value", "effect", "toleration_seconds"}, + LabelValues: []string{key, operator, value, effect, tolerationSeconds}, Value: 1, }) } diff --git a/internal/store/pod_test.go b/internal/store/pod_test.go index 49a5cd942e..8645e87076 100644 --- a/internal/store/pod_test.go +++ b/internal/store/pod_test.go @@ -2123,9 +2123,10 @@ func TestPodStore(t *testing.T) { Want: ` # HELP kube_pod_tolerations Information about the pod tolerations # TYPE kube_pod_tolerations gauge - kube_pod_tolerations{namespace="ns1",pod="pod1",uid="uid1",key="key1",operator="Equal",value="value1",effect="NoSchedule"} 1 - kube_pod_tolerations{namespace="ns1",pod="pod1",uid="uid1",key="key2",operator="Exists"} 1 - kube_pod_tolerations{namespace="ns1",pod="pod1",uid="uid1",key="key3",operator="Equal",value="value3"} 1 + kube_pod_tolerations{effect="",key="",namespace="ns1",operator="",pod="pod1",toleration_seconds="",uid="uid1",value=""} 1 + kube_pod_tolerations{effect="",key="key2",namespace="ns1",operator="Exists",pod="pod1",toleration_seconds="",uid="uid1",value=""} 1 + kube_pod_tolerations{effect="",key="key3",namespace="ns1",operator="Equal",pod="pod1",toleration_seconds="",uid="uid1",value="value3"} 1 + kube_pod_tolerations{effect="NoSchedule",key="key1",namespace="ns1",operator="Equal",pod="pod1",toleration_seconds="",uid="uid1",value="value1"} 1 `, MetricNames: []string{ "kube_pod_tolerations", From 2aa766ee038c37ce8f260b6bfd884a45e0d67607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 31 Oct 2024 17:40:32 +0100 Subject: [PATCH 129/154] serviceaccounts: Expose empty labels --- internal/store/serviceaccount.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/store/serviceaccount.go b/internal/store/serviceaccount.go index 073ee997a0..f7b7f9394f 100644 --- a/internal/store/serviceaccount.go +++ b/internal/store/serviceaccount.go @@ -56,18 +56,16 @@ func createServiceAccountInfoFamilyGenerator() generator.FamilyGenerator { basemetrics.ALPHA, "", wrapServiceAccountFunc(func(sa *v1.ServiceAccount) *metric.Family { - var labelKeys []string - var labelValues []string + var automountToken string if sa.AutomountServiceAccountToken != nil { - labelKeys = append(labelKeys, "automount_token") - labelValues = append(labelValues, strconv.FormatBool(*sa.AutomountServiceAccountToken)) + automountToken = strconv.FormatBool(*sa.AutomountServiceAccountToken) } return &metric.Family{ Metrics: []*metric.Metric{{ - LabelKeys: labelKeys, - LabelValues: labelValues, + LabelKeys: []string{"automount_token"}, + LabelValues: []string{automountToken}, Value: 1, }}, } From 31f793129f184cca6e8823c1eb910cc1558bae73 Mon Sep 17 00:00:00 2001 From: leiwingqueen Date: Fri, 1 Nov 2024 16:16:08 +0800 Subject: [PATCH 130/154] fix big memory overflow --- internal/store/node.go | 29 ++++++++---- internal/store/node_test.go | 88 +++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 9 deletions(-) diff --git a/internal/store/node.go b/internal/store/node.go index 7e2919e522..b6efcffb26 100644 --- a/internal/store/node.go +++ b/internal/store/node.go @@ -18,6 +18,8 @@ package store import ( "context" + "k8s.io/apimachinery/pkg/api/resource" + "math" "strings" basemetrics "k8s.io/component-base/metrics" @@ -353,7 +355,7 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertFloat64(&val), }) } if isAttachableVolumeResourceName(resourceName) { @@ -362,7 +364,7 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertFloat64(&val), }) } if isExtendedResourceName(resourceName) { @@ -371,7 +373,7 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitInteger), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertFloat64(&val), }) } } @@ -407,7 +409,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitCore), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertFloat64(&val), }) case v1.ResourceStorage: fallthrough @@ -419,7 +421,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertFloat64(&val), }) case v1.ResourcePods: ms = append(ms, &metric.Metric{ @@ -427,7 +429,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitInteger), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertFloat64(&val), }) default: if isHugePageResourceName(resourceName) { @@ -436,7 +438,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertFloat64(&val), }) } if isAttachableVolumeResourceName(resourceName) { @@ -445,7 +447,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertFloat64(&val), }) } if isExtendedResourceName(resourceName) { @@ -454,7 +456,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitInteger), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertFloat64(&val), }) } } @@ -530,3 +532,12 @@ func createNodeListWatch(kubeClient clientset.Interface, _ string, _ string) cac }, } } + +const maxValue = math.MaxInt64 / 1000 + +func convertFloat64(q *resource.Quantity) float64 { + if q.Value() > maxValue { + return float64(q.Value()) + } + return float64(q.MilliValue()) / 1000 +} diff --git a/internal/store/node_test.go b/internal/store/node_test.go index bab5670c8f..5eb515a90a 100644 --- a/internal/store/node_test.go +++ b/internal/store/node_test.go @@ -298,6 +298,94 @@ func TestNodeStore(t *testing.T) { `, MetricNames: []string{"kube_node_status_addresses"}, }, + // memory overflow test + { + Obj: &v1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Name: "127.0.0.1", + CreationTimestamp: metav1.Time{Time: time.Unix(1500000000, 0)}, + Labels: map[string]string{ + "node-role.kubernetes.io/master": "", + }, + }, + Spec: v1.NodeSpec{ + Unschedulable: true, + ProviderID: "provider://i-randomidentifier", + PodCIDR: "172.24.10.0/24", + }, + Status: v1.NodeStatus{ + NodeInfo: v1.NodeSystemInfo{ + KernelVersion: "kernel", + KubeletVersion: "kubelet", + KubeProxyVersion: "kubeproxy", + OSImage: "osimage", + ContainerRuntimeVersion: "rkt", + SystemUUID: "6a934e21-5207-4a84-baea-3a952d926c80", + }, + Addresses: []v1.NodeAddress{ + {Type: "InternalIP", Address: "1.2.3.4"}, + }, + Capacity: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("4.3"), + // overflow test + v1.ResourceMemory: resource.MustParse("10000T"), + v1.ResourcePods: resource.MustParse("1000"), + v1.ResourceStorage: resource.MustParse("3G"), + v1.ResourceEphemeralStorage: resource.MustParse("4G"), + v1.ResourceName("nvidia.com/gpu"): resource.MustParse("4"), + }, + Allocatable: v1.ResourceList{ + v1.ResourceCPU: resource.MustParse("3"), + v1.ResourceMemory: resource.MustParse("1G"), + v1.ResourcePods: resource.MustParse("555"), + v1.ResourceStorage: resource.MustParse("2G"), + v1.ResourceEphemeralStorage: resource.MustParse("3G"), + v1.ResourceName("nvidia.com/gpu"): resource.MustParse("1"), + }, + }, + }, + Want: ` + # HELP kube_node_created [STABLE] Unix creation timestamp + # HELP kube_node_info [STABLE] Information about a cluster node. + # HELP kube_node_labels [STABLE] Kubernetes labels converted to Prometheus labels. + # HELP kube_node_role The role of a cluster node. + # HELP kube_node_spec_unschedulable [STABLE] Whether a node can schedule new pods. + # HELP kube_node_status_allocatable [STABLE] The allocatable for different resources of a node that are available for scheduling. + # HELP kube_node_status_capacity [STABLE] The capacity for different resources of a node. + # TYPE kube_node_created gauge + # TYPE kube_node_info gauge + # TYPE kube_node_labels gauge + # TYPE kube_node_role gauge + # TYPE kube_node_spec_unschedulable gauge + # TYPE kube_node_status_allocatable gauge + # TYPE kube_node_status_capacity gauge + kube_node_created{node="127.0.0.1"} 1.5e+09 + kube_node_info{container_runtime_version="rkt",kernel_version="kernel",kubelet_version="kubelet",kubeproxy_version="deprecated",node="127.0.0.1",os_image="osimage",pod_cidr="172.24.10.0/24",provider_id="provider://i-randomidentifier",internal_ip="1.2.3.4",system_uuid="6a934e21-5207-4a84-baea-3a952d926c80"} 1 + kube_node_role{node="127.0.0.1",role="master"} 1 + kube_node_spec_unschedulable{node="127.0.0.1"} 1 + kube_node_status_allocatable{node="127.0.0.1",resource="cpu",unit="core"} 3 + kube_node_status_allocatable{node="127.0.0.1",resource="ephemeral_storage",unit="byte"} 3e+09 + kube_node_status_allocatable{node="127.0.0.1",resource="memory",unit="byte"} 1e+09 + kube_node_status_allocatable{node="127.0.0.1",resource="nvidia_com_gpu",unit="integer"} 1 + kube_node_status_allocatable{node="127.0.0.1",resource="pods",unit="integer"} 555 + kube_node_status_allocatable{node="127.0.0.1",resource="storage",unit="byte"} 2e+09 + kube_node_status_capacity{node="127.0.0.1",resource="cpu",unit="core"} 4.3 + kube_node_status_capacity{node="127.0.0.1",resource="ephemeral_storage",unit="byte"} 4e+09 + kube_node_status_capacity{node="127.0.0.1",resource="memory",unit="byte"} 1e+16 + kube_node_status_capacity{node="127.0.0.1",resource="nvidia_com_gpu",unit="integer"} 4 + kube_node_status_capacity{node="127.0.0.1",resource="pods",unit="integer"} 1000 + kube_node_status_capacity{node="127.0.0.1",resource="storage",unit="byte"} 3e+09 + `, + MetricNames: []string{ + "kube_node_status_capacity", + "kube_node_status_allocatable", + "kube_node_spec_unschedulable", + "kube_node_labels", + "kube_node_role", + "kube_node_info", + "kube_node_created", + }, + }, } for i, c := range cases { c.Func = generator.ComposeMetricGenFuncs(nodeMetricFamilies(nil, nil)) From 2c346763cf709bfed20b62a9a706f165d8d6e3c9 Mon Sep 17 00:00:00 2001 From: leiwingqueen Date: Sat, 2 Nov 2024 09:55:35 +0800 Subject: [PATCH 131/154] change convertValueToFloat64 function name --- internal/store/node.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/internal/store/node.go b/internal/store/node.go index b6efcffb26..d421de707b 100644 --- a/internal/store/node.go +++ b/internal/store/node.go @@ -19,7 +19,6 @@ package store import ( "context" "k8s.io/apimachinery/pkg/api/resource" - "math" "strings" basemetrics "k8s.io/component-base/metrics" @@ -355,7 +354,7 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: convertFloat64(&val), + Value: convertValueToFloat64(&val), }) } if isAttachableVolumeResourceName(resourceName) { @@ -364,7 +363,7 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: convertFloat64(&val), + Value: convertValueToFloat64(&val), }) } if isExtendedResourceName(resourceName) { @@ -373,7 +372,7 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitInteger), }, - Value: convertFloat64(&val), + Value: convertValueToFloat64(&val), }) } } @@ -409,7 +408,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitCore), }, - Value: convertFloat64(&val), + Value: convertValueToFloat64(&val), }) case v1.ResourceStorage: fallthrough @@ -421,7 +420,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: convertFloat64(&val), + Value: convertValueToFloat64(&val), }) case v1.ResourcePods: ms = append(ms, &metric.Metric{ @@ -429,7 +428,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitInteger), }, - Value: convertFloat64(&val), + Value: convertValueToFloat64(&val), }) default: if isHugePageResourceName(resourceName) { @@ -438,7 +437,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: convertFloat64(&val), + Value: convertValueToFloat64(&val), }) } if isAttachableVolumeResourceName(resourceName) { @@ -447,7 +446,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: convertFloat64(&val), + Value: convertValueToFloat64(&val), }) } if isExtendedResourceName(resourceName) { @@ -456,7 +455,7 @@ func createNodeStatusCapacityFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitInteger), }, - Value: convertFloat64(&val), + Value: convertValueToFloat64(&val), }) } } @@ -533,10 +532,8 @@ func createNodeListWatch(kubeClient clientset.Interface, _ string, _ string) cac } } -const maxValue = math.MaxInt64 / 1000 - -func convertFloat64(q *resource.Quantity) float64 { - if q.Value() > maxValue { +func convertValueToFloat64(q *resource.Quantity) float64 { + if q.Value() > resource.MaxMilliValue { return float64(q.Value()) } return float64(q.MilliValue()) / 1000 From e5eb2ed132ca502b6188b9f7b2b5c9f0b1db88f1 Mon Sep 17 00:00:00 2001 From: leiwingqueen Date: Sat, 2 Nov 2024 22:16:15 +0800 Subject: [PATCH 132/154] fix lint error --- internal/store/node.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/store/node.go b/internal/store/node.go index d421de707b..8224062e0d 100644 --- a/internal/store/node.go +++ b/internal/store/node.go @@ -18,9 +18,10 @@ package store import ( "context" - "k8s.io/apimachinery/pkg/api/resource" "strings" + "k8s.io/apimachinery/pkg/api/resource" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/constant" From f94ef65cc70fca45f102207dc4a66393ce84c829 Mon Sep 17 00:00:00 2001 From: leiwingqueen Date: Mon, 4 Nov 2024 10:09:18 +0800 Subject: [PATCH 133/154] fix overflow in other occasion --- internal/store/horizontalpodautoscaler.go | 8 ++++---- internal/store/limitrange.go | 10 +++++----- internal/store/node.go | 15 +++------------ internal/store/pod.go | 10 +++++----- internal/store/resourcequota.go | 4 ++-- internal/store/utils.go | 9 +++++++++ 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/internal/store/horizontalpodautoscaler.go b/internal/store/horizontalpodautoscaler.go index 4e85cf9cd8..b49cdc8546 100644 --- a/internal/store/horizontalpodautoscaler.go +++ b/internal/store/horizontalpodautoscaler.go @@ -217,10 +217,10 @@ func createHPASpecTargetMetric() generator.FamilyGenerator { } if metricTarget.Value != nil { - metricMap[value] = float64(metricTarget.Value.MilliValue()) / 1000 + metricMap[value] = convertValueToFloat64(metricTarget.Value) / 1000 } if metricTarget.AverageValue != nil { - metricMap[average] = float64(metricTarget.AverageValue.MilliValue()) / 1000 + metricMap[average] = convertValueToFloat64(metricTarget.AverageValue) / 1000 } if metricTarget.AverageUtilization != nil { metricMap[utilization] = float64(*metricTarget.AverageUtilization) @@ -276,10 +276,10 @@ func createHPAStatusTargetMetric() generator.FamilyGenerator { } if currentMetric.Value != nil { - metricMap[value] = float64(currentMetric.Value.MilliValue()) / 1000 + metricMap[value] = convertValueToFloat64(currentMetric.Value) } if currentMetric.AverageValue != nil { - metricMap[average] = float64(currentMetric.AverageValue.MilliValue()) / 1000 + metricMap[average] = convertValueToFloat64(currentMetric.AverageValue) } if currentMetric.AverageUtilization != nil { metricMap[utilization] = float64(*currentMetric.AverageUtilization) diff --git a/internal/store/limitrange.go b/internal/store/limitrange.go index ef1bd8ffa4..1be7c1c370 100644 --- a/internal/store/limitrange.go +++ b/internal/store/limitrange.go @@ -49,35 +49,35 @@ var ( for resource, min := range rawLimitRange.Min { ms = append(ms, &metric.Metric{ LabelValues: []string{string(resource), string(rawLimitRange.Type), "min"}, - Value: float64(min.MilliValue()) / 1000, + Value: convertValueToFloat64(&min), }) } for resource, max := range rawLimitRange.Max { ms = append(ms, &metric.Metric{ LabelValues: []string{string(resource), string(rawLimitRange.Type), "max"}, - Value: float64(max.MilliValue()) / 1000, + Value: convertValueToFloat64(&max), }) } for resource, df := range rawLimitRange.Default { ms = append(ms, &metric.Metric{ LabelValues: []string{string(resource), string(rawLimitRange.Type), "default"}, - Value: float64(df.MilliValue()) / 1000, + Value: convertValueToFloat64(&df), }) } for resource, dfR := range rawLimitRange.DefaultRequest { ms = append(ms, &metric.Metric{ LabelValues: []string{string(resource), string(rawLimitRange.Type), "defaultRequest"}, - Value: float64(dfR.MilliValue()) / 1000, + Value: convertValueToFloat64(&dfR), }) } for resource, mLR := range rawLimitRange.MaxLimitRequestRatio { ms = append(ms, &metric.Metric{ LabelValues: []string{string(resource), string(rawLimitRange.Type), "maxLimitRequestRatio"}, - Value: float64(mLR.MilliValue()) / 1000, + Value: convertValueToFloat64(&mLR), }) } } diff --git a/internal/store/node.go b/internal/store/node.go index 8224062e0d..7bd6e4aa8f 100644 --- a/internal/store/node.go +++ b/internal/store/node.go @@ -20,8 +20,6 @@ import ( "context" "strings" - "k8s.io/apimachinery/pkg/api/resource" - basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/constant" @@ -326,7 +324,7 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitCore), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertValueToFloat64(&val), }) case v1.ResourceStorage: fallthrough @@ -338,7 +336,7 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitByte), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertValueToFloat64(&val), }) case v1.ResourcePods: ms = append(ms, &metric.Metric{ @@ -346,7 +344,7 @@ func createNodeStatusAllocatableFamilyGenerator() generator.FamilyGenerator { SanitizeLabelName(string(resourceName)), string(constant.UnitInteger), }, - Value: float64(val.MilliValue()) / 1000, + Value: convertValueToFloat64(&val), }) default: if isHugePageResourceName(resourceName) { @@ -532,10 +530,3 @@ func createNodeListWatch(kubeClient clientset.Interface, _ string, _ string) cac }, } } - -func convertValueToFloat64(q *resource.Quantity) float64 { - if q.Value() > resource.MaxMilliValue { - return float64(q.Value()) - } - return float64(q.MilliValue()) / 1000 -} diff --git a/internal/store/pod.go b/internal/store/pod.go index 8c39017283..7fca04e267 100644 --- a/internal/store/pod.go +++ b/internal/store/pod.go @@ -182,7 +182,7 @@ func createPodContainerResourceLimitsFamilyGenerator() generator.FamilyGenerator case v1.ResourceCPU: ms = append(ms, &metric.Metric{ LabelValues: []string{c.Name, p.Spec.NodeName, SanitizeLabelName(string(resourceName)), string(constant.UnitCore)}, - Value: float64(val.MilliValue()) / 1000, + Value: convertValueToFloat64(&val), }) case v1.ResourceStorage: fallthrough @@ -246,7 +246,7 @@ func createPodContainerResourceRequestsFamilyGenerator() generator.FamilyGenerat case v1.ResourceCPU: ms = append(ms, &metric.Metric{ LabelValues: []string{c.Name, p.Spec.NodeName, SanitizeLabelName(string(resourceName)), string(constant.UnitCore)}, - Value: float64(val.MilliValue()) / 1000, + Value: convertValueToFloat64(&val), }) case v1.ResourceStorage: fallthrough @@ -749,7 +749,7 @@ func createPodInitContainerResourceLimitsFamilyGenerator() generator.FamilyGener case v1.ResourceCPU: ms = append(ms, &metric.Metric{ LabelValues: []string{c.Name, p.Spec.NodeName, SanitizeLabelName(string(resourceName)), string(constant.UnitCore)}, - Value: float64(val.MilliValue()) / 1000, + Value: convertValueToFloat64(&val), }) case v1.ResourceStorage: fallthrough @@ -813,7 +813,7 @@ func createPodInitContainerResourceRequestsFamilyGenerator() generator.FamilyGen case v1.ResourceCPU: ms = append(ms, &metric.Metric{ LabelValues: []string{c.Name, p.Spec.NodeName, SanitizeLabelName(string(resourceName)), string(constant.UnitCore)}, - Value: float64(val.MilliValue()) / 1000, + Value: convertValueToFloat64(&val), }) case v1.ResourceStorage: fallthrough @@ -1122,7 +1122,7 @@ func createPodOverheadCPUCoresFamilyGenerator() generator.FamilyGenerator { for resourceName, val := range p.Spec.Overhead { if resourceName == v1.ResourceCPU { ms = append(ms, &metric.Metric{ - Value: float64(val.MilliValue()) / 1000, + Value: convertValueToFloat64(&val), }) } } diff --git a/internal/store/resourcequota.go b/internal/store/resourcequota.go index adaf4a838e..6fc017cfc6 100644 --- a/internal/store/resourcequota.go +++ b/internal/store/resourcequota.go @@ -74,13 +74,13 @@ func resourceQuotaMetricFamilies(allowAnnotationsList, allowLabelsList []string) for res, qty := range r.Status.Hard { ms = append(ms, &metric.Metric{ LabelValues: []string{string(res), "hard"}, - Value: float64(qty.MilliValue()) / 1000, + Value: convertValueToFloat64(&qty), }) } for res, qty := range r.Status.Used { ms = append(ms, &metric.Metric{ LabelValues: []string{string(res), "used"}, - Value: float64(qty.MilliValue()) / 1000, + Value: convertValueToFloat64(&qty), }) } diff --git a/internal/store/utils.go b/internal/store/utils.go index f1dd5404ca..ece2b931d8 100644 --- a/internal/store/utils.go +++ b/internal/store/utils.go @@ -18,6 +18,7 @@ package store import ( "fmt" + "k8s.io/apimachinery/pkg/api/resource" "regexp" "sort" "strconv" @@ -215,3 +216,11 @@ func mergeKeyValues(keyValues ...[]string) (keys, values []string) { return keys, values } + +// convertValueToFloat64 converts a resource.Quantity to a float64. +func convertValueToFloat64(q *resource.Quantity) float64 { + if q.Value() > resource.MaxMilliValue { + return float64(q.Value()) + } + return float64(q.MilliValue()) / 1000 +} From 70088ed1eafe8e9aaa2d502678218ad99e05b287 Mon Sep 17 00:00:00 2001 From: Haley Wang Date: Mon, 4 Nov 2024 16:38:57 +0800 Subject: [PATCH 134/154] apply review comment --- docs/metrics/extend/customresourcestate-metrics.md | 3 ++- pkg/customresourcestate/registry_factory.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/metrics/extend/customresourcestate-metrics.md b/docs/metrics/extend/customresourcestate-metrics.md index c28b04b0f8..431fd0f1bc 100644 --- a/docs/metrics/extend/customresourcestate-metrics.md +++ b/docs/metrics/extend/customresourcestate-metrics.md @@ -337,7 +337,8 @@ Supported types are: * `nil` is generally mapped to `0.0` if NilIsZero is `true`, otherwise it will throw an error * for bool `true` is mapped to `1.0` and `false` is mapped to `0.0` * for string the following logic applies - * `"true"` and `"yes"` are mapped to `1.0`, `"false"`, `"no"` and `"unknown"` are mapped to `0.0` (all case-insensitive) + * `"true"` and `"yes"` are mapped to `1.0`, `"false"` and `"no"` are mapped to `0.0` (all case-insensitive) + * `"unknown"` is mapped to `-1.0` (all case-insensitive) * RFC3339 times are parsed to float timestamp * Quantities like "250m" or "512Gi" are parsed to float using * Percentages ending with a "%" are parsed to float diff --git a/pkg/customresourcestate/registry_factory.go b/pkg/customresourcestate/registry_factory.go index 39c261bd2e..26639e81ae 100644 --- a/pkg/customresourcestate/registry_factory.go +++ b/pkg/customresourcestate/registry_factory.go @@ -727,7 +727,7 @@ func toFloat64(value interface{}, nilIsZero bool) (float64, error) { } return 0, nil case string: - // The string contains a boolean as a string + // The string is a boolean or `"unknown"` according to https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Condition normalized := strings.ToLower(value.(string)) if normalized == "true" || normalized == "yes" { return 1, nil @@ -736,7 +736,7 @@ func toFloat64(value interface{}, nilIsZero bool) (float64, error) { return 0, nil } if normalized == "unknown" { - return 0, nil + return -1, nil } // The string contains a RFC3339 timestamp if t, e := time.Parse(time.RFC3339, value.(string)); e == nil { From ea648da9c68a16ebef3ac5048029e7093b58c8f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:08:25 +0000 Subject: [PATCH 135/154] build(deps): Bump github.com/fsnotify/fsnotify from 1.7.0 to 1.8.0 Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.7.0 to 1.8.0. - [Release notes](https://github.com/fsnotify/fsnotify/releases) - [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md) - [Commits](https://github.com/fsnotify/fsnotify/compare/v1.7.0...v1.8.0) --- updated-dependencies: - dependency-name: github.com/fsnotify/fsnotify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 022f071465..bd8df0180b 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23.0 require ( github.com/KimMachineGun/automemlimit v0.6.1 github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 - github.com/fsnotify/fsnotify v1.7.0 + github.com/fsnotify/fsnotify v1.8.0 github.com/go-logr/logr v1.4.2 github.com/gobuffalo/flect v1.0.3 github.com/google/go-cmp v0.6.0 diff --git a/go.sum b/go.sum index c4a6064c02..70e5196afa 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxER github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= +github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= From 37f10f06023dac913c8581c9dc0d05156d3da0e4 Mon Sep 17 00:00:00 2001 From: leiwingqueen Date: Mon, 4 Nov 2024 23:33:53 +0800 Subject: [PATCH 136/154] fix lint --- internal/store/utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/store/utils.go b/internal/store/utils.go index ece2b931d8..5c809c2d0b 100644 --- a/internal/store/utils.go +++ b/internal/store/utils.go @@ -18,12 +18,13 @@ package store import ( "fmt" - "k8s.io/apimachinery/pkg/api/resource" "regexp" "sort" "strconv" "strings" + "k8s.io/apimachinery/pkg/api/resource" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/validation" From 7980f03c52efb5a51d2fc6c1f0b8c94c028a6a14 Mon Sep 17 00:00:00 2001 From: leiwingqueen Date: Tue, 5 Nov 2024 00:02:19 +0800 Subject: [PATCH 137/154] fix convert float64 error --- internal/store/horizontalpodautoscaler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/store/horizontalpodautoscaler.go b/internal/store/horizontalpodautoscaler.go index b49cdc8546..3994f14c39 100644 --- a/internal/store/horizontalpodautoscaler.go +++ b/internal/store/horizontalpodautoscaler.go @@ -217,10 +217,10 @@ func createHPASpecTargetMetric() generator.FamilyGenerator { } if metricTarget.Value != nil { - metricMap[value] = convertValueToFloat64(metricTarget.Value) / 1000 + metricMap[value] = convertValueToFloat64(metricTarget.Value) } if metricTarget.AverageValue != nil { - metricMap[average] = convertValueToFloat64(metricTarget.AverageValue) / 1000 + metricMap[average] = convertValueToFloat64(metricTarget.AverageValue) } if metricTarget.AverageUtilization != nil { metricMap[utilization] = float64(*metricTarget.AverageUtilization) From c67f02f0f3763f0f5cafa7a9428624e0820f2f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Tue, 5 Nov 2024 10:58:10 +0100 Subject: [PATCH 138/154] Apply suggestions from code review --- internal/store/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/store/utils.go b/internal/store/utils.go index 5c809c2d0b..5cebe03ca4 100644 --- a/internal/store/utils.go +++ b/internal/store/utils.go @@ -218,7 +218,7 @@ func mergeKeyValues(keyValues ...[]string) (keys, values []string) { return keys, values } -// convertValueToFloat64 converts a resource.Quantity to a float64. +// convertValueToFloat64 converts a resource.Quantity to a float64 and checks for a possible overflow in the value. func convertValueToFloat64(q *resource.Quantity) float64 { if q.Value() > resource.MaxMilliValue { return float64(q.Value()) From fac6119d43f284443d1af024cdacb11d22238d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Tue, 5 Nov 2024 23:06:10 +0100 Subject: [PATCH 139/154] chore: Allow setting rounds in benchmark --- tests/compare_benchmarks.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/compare_benchmarks.sh b/tests/compare_benchmarks.sh index d05a52dbde..b501e77d06 100755 --- a/tests/compare_benchmarks.sh +++ b/tests/compare_benchmarks.sh @@ -6,18 +6,22 @@ set -o pipefail # error on unset variables set -u -[[ "$#" -eq 1 ]] || echo "One argument required, $# provided." +[[ "$#" -le 2 ]] || echo "At least one argument required, $# provided." REF_CURRENT="$(git rev-parse --abbrev-ref HEAD)" REF_TO_COMPARE=$1 +COUNT=${2:-"1"} + +echo "Running benchmarks ${COUNT} time(s)" + RESULT_CURRENT="$(mktemp)-${REF_CURRENT}" RESULT_TO_COMPARE="$(mktemp)-${REF_TO_COMPARE}" echo "" echo "### Testing ${REF_CURRENT}" -go test -benchmem -run=NONE -bench=. ./... | tee "${RESULT_CURRENT}" +go test -benchmem -run=NONE -bench=. -count="${COUNT}" ./... | tee "${RESULT_CURRENT}" echo "" echo "### Done testing ${REF_CURRENT}" @@ -27,7 +31,7 @@ echo "### Testing ${REF_TO_COMPARE}" git checkout "${REF_TO_COMPARE}" -go test -benchmem -run=NONE -bench=. ./... | tee "${RESULT_TO_COMPARE}" +go test -benchmem -run=NONE -bench=. -count="${COUNT}" ./... | tee "${RESULT_TO_COMPARE}" echo "" echo "### Done testing ${REF_TO_COMPARE}" From b0e9be550b640538fdb15b8149292ac2ecd3fc51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 6 Nov 2024 09:10:20 +0100 Subject: [PATCH 140/154] fix: Remove log output from benchmark Without this change Info logs appear in the benchmark ok k8s.io/kube-state-metrics/v2/pkg/allowdenylist 0.005s I1106 08:50:22.006480 144965 builder.go:280] "Active resources" activeStoreNames="certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments" goos: linux goarch: amd64 pkg: k8s.io/kube-state-metrics/v2/pkg/app cpu: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz BenchmarkKubeStateMetrics/GenerateMetrics-8 1 1001291639 ns/op 67578008 B/op 582810 allocs/op --- pkg/app/server_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/app/server_test.go b/pkg/app/server_test.go index 9f6c0be970..26fec175d2 100644 --- a/pkg/app/server_test.go +++ b/pkg/app/server_test.go @@ -19,6 +19,7 @@ package app import ( "bytes" "context" + "flag" "fmt" "io" "net/http/httptest" @@ -40,6 +41,7 @@ import ( "k8s.io/client-go/kubernetes/fake" "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" + "k8s.io/klog/v2" samplev1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1" samplefake "k8s.io/sample-controller/pkg/generated/clientset/versioned/fake" @@ -70,6 +72,10 @@ func BenchmarkKubeStateMetrics(b *testing.B) { b.Errorf("error injecting resources: %v", err) } ctx, cancel := context.WithCancel(context.Background()) + + klogFlags := flag.NewFlagSet("klog", flag.ExitOnError) + klog.InitFlags(klogFlags) + klogFlags.Set("logtostderr", "false") defer cancel() reg := prometheus.NewRegistry() From 02b6a214c6d0cab1b70481642a67b17b486e3651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 6 Nov 2024 09:13:32 +0100 Subject: [PATCH 141/154] chore: Run the benchmark for two rounds --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 003868c7dd..f49410532b 100644 --- a/Makefile +++ b/Makefile @@ -97,8 +97,8 @@ validate-template: generate-template # the two. test-benchmark-compare: @git fetch - ./tests/compare_benchmarks.sh main - ./tests/compare_benchmarks.sh ${LATEST_RELEASE_BRANCH} + ./tests/compare_benchmarks.sh main 2 + ./tests/compare_benchmarks.sh ${LATEST_RELEASE_BRANCH} 2 all: all-container From 030353285135bacda59e5affb732959d9556c651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 6 Nov 2024 09:46:34 +0100 Subject: [PATCH 142/154] chore: Integrate benchmark output in GHA The code comes from ivanvc in https://github.com/etcd-io/bbolt/pull/750 --- .github/workflows/ci.yml | 12 +++++++++++- tests/compare_benchmarks.sh | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a42280f7ff..bc78eae658 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -164,7 +164,17 @@ jobs: - name: Benchmark tests run: | - make test-benchmark-compare + BENCHSTAT_OUTPUT_FILE=result.txt make test-benchmark-compare + - run: | + echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" + cat result.txt >> "$GITHUB_STEP_SUMMARY" + echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" + cat <> "$GITHUB_STEP_SUMMARY" +
+ The table shows the median and 95% confidence interval (CI) summaries for each benchmark comparing the HEAD and the BASE, and an A/B comparison under "vs base". The last column shows the statistical p-value with ten runs (n=10). + The last row has the Geometric Mean (geomean) for the given rows in the table. + Refer to [benchstat's documentation](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat) for more help. + EOL ci-build-kube-state-metrics: name: ci-build-kube-state-metrics diff --git a/tests/compare_benchmarks.sh b/tests/compare_benchmarks.sh index b501e77d06..fdcd17e754 100755 --- a/tests/compare_benchmarks.sh +++ b/tests/compare_benchmarks.sh @@ -9,7 +9,7 @@ set -u [[ "$#" -le 2 ]] || echo "At least one argument required, $# provided." REF_CURRENT="$(git rev-parse --abbrev-ref HEAD)" -REF_TO_COMPARE=$1 +REF_TO_COMPARE="${1}" COUNT=${2:-"1"} @@ -42,4 +42,8 @@ echo "" echo "### Result" echo "old=${REF_TO_COMPARE} new=${REF_CURRENT}" -benchstat "${RESULT_TO_COMPARE}" "${RESULT_CURRENT}" +if [[ -z "${BENCHSTAT_OUTPUT_FILE}" ]]; then + benchstat "${REF_TO_COMPARE}=${RESULT_TO_COMPARE}" "${REF_CURRENT}=${RESULT_CURRENT}" +else + benchstat "${REF_TO_COMPARE}=${RESULT_TO_COMPARE}" "${REF_CURRENT}=${RESULT_CURRENT}" | tee -a "${BENCHSTAT_OUTPUT_FILE}" +fi From fa27721993080921f65a006cfeaa7a1009c7027e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 6 Nov 2024 11:35:23 +0100 Subject: [PATCH 143/154] Update .github/workflows/ci.yml Co-authored-by: Pranshu Srivastava --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc78eae658..5e1a8d8599 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,7 +173,7 @@ jobs:
The table shows the median and 95% confidence interval (CI) summaries for each benchmark comparing the HEAD and the BASE, and an A/B comparison under "vs base". The last column shows the statistical p-value with ten runs (n=10). The last row has the Geometric Mean (geomean) for the given rows in the table. - Refer to [benchstat's documentation](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat) for more help. + Refer to benchstat's documentation for more help. EOL ci-build-kube-state-metrics: From 9c61d7ea81b7b25e4ea376d9040331468e7c9948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 6 Nov 2024 17:43:35 +0100 Subject: [PATCH 144/154] chore: Fix broken CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e1a8d8599..71df618f09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,7 +173,7 @@ jobs:
The table shows the median and 95% confidence interval (CI) summaries for each benchmark comparing the HEAD and the BASE, and an A/B comparison under "vs base". The last column shows the statistical p-value with ten runs (n=10). The last row has the Geometric Mean (geomean) for the given rows in the table. - Refer to benchstat's documentation for more help. + Refer to benchstat's documentation for more help. EOL ci-build-kube-state-metrics: From 1734bd840305419db324a69b4a8edace85b2b76d Mon Sep 17 00:00:00 2001 From: Henry Wu Date: Thu, 7 Nov 2024 00:07:36 +0000 Subject: [PATCH 145/154] Remove redundant factories array since it is not written after construction. --- pkg/app/server.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/app/server.go b/pkg/app/server.go index 8719797cb6..8ab3ad54f8 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -52,7 +52,6 @@ import ( "k8s.io/kube-state-metrics/v2/internal/discovery" "k8s.io/kube-state-metrics/v2/internal/store" "k8s.io/kube-state-metrics/v2/pkg/allowdenylist" - "k8s.io/kube-state-metrics/v2/pkg/customresource" "k8s.io/kube-state-metrics/v2/pkg/customresourcestate" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" "k8s.io/kube-state-metrics/v2/pkg/metricshandler" @@ -175,8 +174,6 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { return err } - var factories []customresource.RegistryFactory - if opts.CustomResourceConfigFile != "" { crcFile, err := os.ReadFile(filepath.Clean(opts.CustomResourceConfigFile)) if err != nil { @@ -189,11 +186,7 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error { } - resources := make([]string, len(factories)) - - for i, factory := range factories { - resources[i] = factory.Name() - } + resources := []string{} switch { case len(opts.Resources) == 0 && !opts.CustomResourcesOnly: From 076987a505f4657582125886383ec68eba5ec45d Mon Sep 17 00:00:00 2001 From: Indresh-Prakash Date: Sat, 2 Nov 2024 12:10:41 +0000 Subject: [PATCH 146/154] Add kube_job_status_suspended metric --- docs/metrics/workload/job-metrics.md | 1 + internal/store/job.go | 24 ++++++++++++++++ internal/store/job_test.go | 41 +++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/docs/metrics/workload/job-metrics.md b/docs/metrics/workload/job-metrics.md index d5959c4dd7..c5283340f2 100644 --- a/docs/metrics/workload/job-metrics.md +++ b/docs/metrics/workload/job-metrics.md @@ -17,3 +17,4 @@ | kube_job_complete | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | STABLE | | kube_job_failed | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | STABLE | | kube_job_created | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace> | STABLE | +| kube_job_status_suspended | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | EXPERIMENTAL | diff --git a/internal/store/job.go b/internal/store/job.go index 8dd53b0a19..b529a99ff3 100644 --- a/internal/store/job.go +++ b/internal/store/job.go @@ -355,6 +355,30 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat } }), ), + *generator.NewFamilyGeneratorWithStability( + "kube_job_status_suspended", + "The number of pods which reached Phase Suspended.", + metric.Gauge, + basemetrics.ALPHA, + "", + wrapJobFunc(func(j *v1batch.Job) *metric.Family { + ms := []*metric.Metric{} + for _, c := range j.Status.Conditions { + if c.Type == v1batch.JobSuspended { + metrics := addConditionMetrics(c.Status) + for _, m := range metrics { + metric := m + metric.LabelKeys = []string{"condition"} + ms = append(ms, metric) + } + } + } + + return &metric.Family{ + Metrics: ms, + } + }), + ), *generator.NewFamilyGeneratorWithStability( "kube_job_owner", "Information about the Job's owner.", diff --git a/internal/store/job_test.go b/internal/store/job_test.go index b808c321b5..52337fffb9 100644 --- a/internal/store/job_test.go +++ b/internal/store/job_test.go @@ -77,7 +77,10 @@ func TestJobStore(t *testing.T) { # HELP kube_job_status_start_time [STABLE] StartTime represents time when the job was acknowledged by the Job Manager. # TYPE kube_job_status_start_time gauge # HELP kube_job_status_succeeded [STABLE] The number of pods which reached Phase Succeeded. - # TYPE kube_job_status_succeeded gauge` + # TYPE kube_job_status_succeeded gauge + # HELP kube_job_status_suspended The number of pods which reached Phase Suspended. + # TYPE kube_job_status_suspended gauge + ` cases := []generateMetricsTestCase{ { @@ -272,6 +275,42 @@ func TestJobStore(t *testing.T) { kube_job_status_failed{job_name="SuccessfulJob2NoActiveDeadlineSeconds",namespace="ns1"} 0 kube_job_status_start_time{job_name="SuccessfulJob2NoActiveDeadlineSeconds",namespace="ns1"} 1.495800607e+09 kube_job_status_succeeded{job_name="SuccessfulJob2NoActiveDeadlineSeconds",namespace="ns1"} 1 +`, + }, + { + Obj: &v1batch.Job{ + ObjectMeta: metav1.ObjectMeta{ + Name: "SuspendedNoActiveDeadlineSeconds", + Namespace: "ns1", + Generation: 1, + }, + Status: v1batch.JobStatus{ + Active: 0, + Failed: 0, + Succeeded: 0, + StartTime: &metav1.Time{Time: SuccessfulJob2StartTime}, + Conditions: []v1batch.JobCondition{ + {Type: v1batch.JobSuspended, Status: v1.ConditionTrue}, + }, + }, + Spec: v1batch.JobSpec{ + Suspend: &trueValue, + Parallelism: &Parallelism1, + Completions: &Completions1, + }, + }, + Want: metadata + ` + kube_job_owner{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1",owner_is_controller="",owner_kind="",owner_name=""} 1 + kube_job_info{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1 + kube_job_spec_completions{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1 + kube_job_spec_parallelism{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1 + kube_job_status_active{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 0 + kube_job_status_failed{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 0 + kube_job_status_start_time{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1.495800607e+09 + kube_job_status_succeeded{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 0 + kube_job_status_suspended{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1",condition="false"} 0 + kube_job_status_suspended{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1",condition="true"} 1 + kube_job_status_suspended{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1",condition="unknown"} 0 `, }, } From 34abbcf20208b14ed727d4be64670401540294a1 Mon Sep 17 00:00:00 2001 From: Indresh2410 Date: Wed, 6 Nov 2024 16:02:38 +0000 Subject: [PATCH 147/154] Address Review Comments --- internal/store/job.go | 10 ++++------ internal/store/job_test.go | 39 +++++++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/internal/store/job.go b/internal/store/job.go index b529a99ff3..bac4806384 100644 --- a/internal/store/job.go +++ b/internal/store/job.go @@ -26,6 +26,7 @@ import ( generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" v1batch "k8s.io/api/batch/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" @@ -365,12 +366,9 @@ func jobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat ms := []*metric.Metric{} for _, c := range j.Status.Conditions { if c.Type == v1batch.JobSuspended { - metrics := addConditionMetrics(c.Status) - for _, m := range metrics { - metric := m - metric.LabelKeys = []string{"condition"} - ms = append(ms, metric) - } + ms = append(ms, &metric.Metric{ + Value: boolFloat64(c.Status == v1.ConditionTrue), + }) } } diff --git a/internal/store/job_test.go b/internal/store/job_test.go index 52337fffb9..67d0a22633 100644 --- a/internal/store/job_test.go +++ b/internal/store/job_test.go @@ -44,6 +44,7 @@ var ( func TestJobStore(t *testing.T) { var trueValue = true + var falseValue = false // Fixed metadata on type and help text. We prepend this to every expected // output so we only have to modify a single place when doing adjustments. @@ -308,9 +309,41 @@ func TestJobStore(t *testing.T) { kube_job_status_failed{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 0 kube_job_status_start_time{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1.495800607e+09 kube_job_status_succeeded{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 0 - kube_job_status_suspended{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1",condition="false"} 0 - kube_job_status_suspended{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1",condition="true"} 1 - kube_job_status_suspended{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1",condition="unknown"} 0 + kube_job_status_suspended{job_name="SuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1 +`, + }, + { + Obj: &v1batch.Job{ + ObjectMeta: metav1.ObjectMeta{ + Name: "UnsuspendedNoActiveDeadlineSeconds", + Namespace: "ns1", + Generation: 1, + }, + Status: v1batch.JobStatus{ + Active: 0, + Failed: 0, + Succeeded: 0, + StartTime: &metav1.Time{Time: SuccessfulJob2StartTime}, + Conditions: []v1batch.JobCondition{ + {Type: v1batch.JobSuspended, Status: v1.ConditionFalse}, + }, + }, + Spec: v1batch.JobSpec{ + Suspend: &falseValue, + Parallelism: &Parallelism1, + Completions: &Completions1, + }, + }, + Want: metadata + ` + kube_job_owner{job_name="UnsuspendedNoActiveDeadlineSeconds",namespace="ns1",owner_is_controller="",owner_kind="",owner_name=""} 1 + kube_job_info{job_name="UnsuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1 + kube_job_spec_completions{job_name="UnsuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1 + kube_job_spec_parallelism{job_name="UnsuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1 + kube_job_status_active{job_name="UnsuspendedNoActiveDeadlineSeconds",namespace="ns1"} 0 + kube_job_status_failed{job_name="UnsuspendedNoActiveDeadlineSeconds",namespace="ns1"} 0 + kube_job_status_start_time{job_name="UnsuspendedNoActiveDeadlineSeconds",namespace="ns1"} 1.495800607e+09 + kube_job_status_succeeded{job_name="UnsuspendedNoActiveDeadlineSeconds",namespace="ns1"} 0 + kube_job_status_suspended{job_name="UnsuspendedNoActiveDeadlineSeconds",namespace="ns1"} 0 `, }, } From ba7ff1a0e5dce693709f06e84236b7e4fdca1514 Mon Sep 17 00:00:00 2001 From: Indresh2410 Date: Wed, 6 Nov 2024 16:10:02 +0000 Subject: [PATCH 148/154] Address Review Comments --- docs/metrics/workload/job-metrics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/metrics/workload/job-metrics.md b/docs/metrics/workload/job-metrics.md index c5283340f2..21d02143b5 100644 --- a/docs/metrics/workload/job-metrics.md +++ b/docs/metrics/workload/job-metrics.md @@ -17,4 +17,4 @@ | kube_job_complete | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | STABLE | | kube_job_failed | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | STABLE | | kube_job_created | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace> | STABLE | -| kube_job_status_suspended | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | EXPERIMENTAL | +| kube_job_status_completion_time | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace> | EXPERIMENTAL | \ No newline at end of file From b2c8fa7837e75ce6139f8bb4e56ce8ef023d563d Mon Sep 17 00:00:00 2001 From: Indresh2410 Date: Wed, 6 Nov 2024 16:12:17 +0000 Subject: [PATCH 149/154] Address Review Comments --- docs/metrics/workload/job-metrics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/metrics/workload/job-metrics.md b/docs/metrics/workload/job-metrics.md index 21d02143b5..24cd15460a 100644 --- a/docs/metrics/workload/job-metrics.md +++ b/docs/metrics/workload/job-metrics.md @@ -17,4 +17,4 @@ | kube_job_complete | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | STABLE | | kube_job_failed | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | STABLE | | kube_job_created | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace> | STABLE | -| kube_job_status_completion_time | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace> | EXPERIMENTAL | \ No newline at end of file +| kube_job_status_suspended | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace> | EXPERIMENTAL | \ No newline at end of file From 7a54a8ebf0e8b9afa092b308e905bd3f12c0430e Mon Sep 17 00:00:00 2001 From: Indresh2410 Date: Thu, 7 Nov 2024 05:52:47 +0000 Subject: [PATCH 150/154] Add new line --- docs/metrics/workload/job-metrics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/metrics/workload/job-metrics.md b/docs/metrics/workload/job-metrics.md index 24cd15460a..807d533288 100644 --- a/docs/metrics/workload/job-metrics.md +++ b/docs/metrics/workload/job-metrics.md @@ -17,4 +17,4 @@ | kube_job_complete | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | STABLE | | kube_job_failed | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace>
`condition`=<true\|false\|unknown> | STABLE | | kube_job_created | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace> | STABLE | -| kube_job_status_suspended | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace> | EXPERIMENTAL | \ No newline at end of file +| kube_job_status_suspended | Gauge | | `job_name`=<job-name>
`namespace`=<job-namespace> | EXPERIMENTAL | From c5665b69bf2d7f043298f33068ad8204b91232e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 7 Nov 2024 08:15:02 +0100 Subject: [PATCH 151/154] chore: Bump versions --- Makefile | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- tools/go.mod | 16 ++++++++-------- tools/go.sum | 32 ++++++++++++++++---------------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index f49410532b..563e5ceaac 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ GIT_COMMIT ?= $(shell git rev-parse --short HEAD) OS ?= $(shell uname -s | tr A-Z a-z) ALL_ARCH = amd64 arm arm64 ppc64le s390x PKG = github.com/prometheus/common -PROMETHEUS_VERSION = 2.54.1 -GO_VERSION = 1.23.2 +PROMETHEUS_VERSION = 2.55.1 +GO_VERSION = 1.23.3 IMAGE = $(REGISTRY)/kube-state-metrics MULTI_ARCH_IMG = $(IMAGE)-$(ARCH) USER ?= $(shell id -u -n) diff --git a/go.mod b/go.mod index bd8df0180b..9fedb43b6d 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( k8s.io/component-base v0.31.2 k8s.io/klog/v2 v2.130.1 k8s.io/sample-controller v0.31.2 - k8s.io/utils v0.0.0-20240821151609-f90d01438635 + k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 ) require ( diff --git a/go.sum b/go.sum index 70e5196afa..94c6b025e3 100644 --- a/go.sum +++ b/go.sum @@ -254,8 +254,8 @@ k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7F k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/sample-controller v0.31.2 h1:1Nygz1ZsKA13cjz6jP3ZM5HwZap+TFx1CA07zqWuJYY= k8s.io/sample-controller v0.31.2/go.mod h1:saA7VVGDYlpNiQ54GKXGHFEuG/R7bbSal2KWPmCiAtg= -k8s.io/utils v0.0.0-20240821151609-f90d01438635 h1:2wThSvJoW/Ncn9TmQEYXRnevZXi2duqHWf5OX9S3zjI= -k8s.io/utils v0.0.0-20240821151609-f90d01438635/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 h1:jGnCPejIetjiy2gqaJ5V0NLwTpF4wbQ6cZIItJCSHno= +k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/tools/go.mod b/tools/go.mod index 302640a667..414e3c5198 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -8,7 +8,7 @@ require ( github.com/google/go-jsonnet v0.20.0 github.com/hairyhenderson/gomplate/v3 v3.11.8 github.com/jsonnet-bundler/jsonnet-bundler v0.6.0 - golang.org/x/perf v0.0.0-20240604174448-3b48cf0e0164 + golang.org/x/perf v0.0.0-20241004173025-94b0db8a2472 ) require ( @@ -125,14 +125,14 @@ require ( go4.org/intern v0.0.0-20230205224052-192e9f60865c // indirect go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect gocloud.dev v0.25.1-0.20220408200107-09b10f7359f7 // indirect - golang.org/x/crypto v0.24.0 // indirect + golang.org/x/crypto v0.28.0 // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/term v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect diff --git a/tools/go.sum b/tools/go.sum index 69bf42344a..b8b121072b 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -920,8 +920,8 @@ golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1021,8 +1021,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1043,10 +1043,10 @@ golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= -golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/perf v0.0.0-20240604174448-3b48cf0e0164 h1:EUu0oOwLbhVs3v7r1ulLp3a3czQ3XkvKcBGOMfft+nw= -golang.org/x/perf v0.0.0-20240604174448-3b48cf0e0164/go.mod h1:yzNzwBKxdK25sFy9NWFu/abeZOeugePuXQfvVIDA8os= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/perf v0.0.0-20241004173025-94b0db8a2472 h1:kifBcAOhV9fBI1RN0vai5zSvvOjhBTjvymGbRIKB0M4= +golang.org/x/perf v0.0.0-20241004173025-94b0db8a2472/go.mod h1:wLQChX6XSStqGCueXQW/40U3ucTK44jnINeZ0omqPIQ= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1060,8 +1060,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1156,8 +1156,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1165,8 +1165,8 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1180,8 +1180,8 @@ golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From d7d2d89017015a2296bd74ebf26a30ee08d90084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 8 Nov 2024 10:32:47 +0100 Subject: [PATCH 152/154] Update docs/metrics/extend/customresourcestate-metrics.md --- docs/metrics/extend/customresourcestate-metrics.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/metrics/extend/customresourcestate-metrics.md b/docs/metrics/extend/customresourcestate-metrics.md index 431fd0f1bc..c28b04b0f8 100644 --- a/docs/metrics/extend/customresourcestate-metrics.md +++ b/docs/metrics/extend/customresourcestate-metrics.md @@ -337,8 +337,7 @@ Supported types are: * `nil` is generally mapped to `0.0` if NilIsZero is `true`, otherwise it will throw an error * for bool `true` is mapped to `1.0` and `false` is mapped to `0.0` * for string the following logic applies - * `"true"` and `"yes"` are mapped to `1.0`, `"false"` and `"no"` are mapped to `0.0` (all case-insensitive) - * `"unknown"` is mapped to `-1.0` (all case-insensitive) + * `"true"` and `"yes"` are mapped to `1.0`, `"false"`, `"no"` and `"unknown"` are mapped to `0.0` (all case-insensitive) * RFC3339 times are parsed to float timestamp * Quantities like "250m" or "512Gi" are parsed to float using * Percentages ending with a "%" are parsed to float From cad704d488926560de36d97cdfc195fe959770fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 8 Nov 2024 10:32:59 +0100 Subject: [PATCH 153/154] Update pkg/customresourcestate/registry_factory.go --- pkg/customresourcestate/registry_factory.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/customresourcestate/registry_factory.go b/pkg/customresourcestate/registry_factory.go index 26639e81ae..5d2f22b068 100644 --- a/pkg/customresourcestate/registry_factory.go +++ b/pkg/customresourcestate/registry_factory.go @@ -732,12 +732,9 @@ func toFloat64(value interface{}, nilIsZero bool) (float64, error) { if normalized == "true" || normalized == "yes" { return 1, nil } - if normalized == "false" || normalized == "no" { + if normalized == "false" || normalized == "no" || normalized == "unknown" { return 0, nil } - if normalized == "unknown" { - return -1, nil - } // The string contains a RFC3339 timestamp if t, e := time.Parse(time.RFC3339, value.(string)); e == nil { return float64(t.Unix()), nil From b4d98d7b401a0e384cce9a353d53a67cd34a2071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 30 Oct 2024 13:17:04 +0100 Subject: [PATCH 154/154] chore: Cut v2.14.0 --- CHANGELOG.md | 23 +++++++++++++++++++ README.md | 6 ++--- data.yaml | 6 ++--- .../autosharding/cluster-role-binding.yaml | 2 +- examples/autosharding/cluster-role.yaml | 2 +- examples/autosharding/role-binding.yaml | 2 +- examples/autosharding/role.yaml | 2 +- examples/autosharding/service-account.yaml | 2 +- examples/autosharding/service.yaml | 2 +- examples/autosharding/statefulset.yaml | 6 ++--- .../cluster-role-binding.yaml | 2 +- examples/daemonsetsharding/cluster-role.yaml | 2 +- .../daemonsetsharding/daemonset-service.yaml | 2 +- examples/daemonsetsharding/daemonset.yaml | 6 ++--- .../daemonsetsharding/deployment-service.yaml | 2 +- examples/daemonsetsharding/deployment.yaml | 6 ++--- .../daemonsetsharding/service-account.yaml | 2 +- examples/standard/cluster-role-binding.yaml | 2 +- examples/standard/cluster-role.yaml | 2 +- examples/standard/deployment.yaml | 6 ++--- examples/standard/service-account.yaml | 2 +- examples/standard/service.yaml | 2 +- 22 files changed, 56 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97397f9ce2..da3bbd4f04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +## v2.14.0 / 2024-11-08 + +### Note + +* This release builds with Golang `v1.23.3` +* This release builds with `k8s.io/client-go`: `v0.31.2` +* This release removes `kube_endpoint_address_not_ready` and `kube_endpoint_address_available` which have been deprecated in 2022. Please use `kube_endpoint_address`as a replacement. + +* [BUGFIX] Use --track-unscheduled-pods to select unscheduled pods in Daemonset sharding by @CatherineF-dev in +* [BUGFIX] Install tools so VERSION gets set by @mrueg in +* [BUGFIX] Syntax errors in kube-state-metrics.libsonnet by @jeffmccune in +* [BUGFIX] Set kube_job_status_failed metric even when there are no job.Status.Conditions present by @richabanker in +* [BUGFIX] de-duplication of custom resource metrics by @bartlettc22 in +* [BUGFIX] Configure sharding every time MetricsHandler.Run runs by @wallee94 in +* [BUGFIX] Panic in `util.GVRFromType` for core objects by @L3n41c in +* [BUGFIX] Big memory value overflow by @leiwingqueen in +* [BUGFIX] Expose empty labels by @mrueg in +* [BUGFIX] CustomResourceMetrics: Convert status condition Unknown to a valid value by @Haleygo in +* [CHANGE] Remove deprecated endpoint address metric by @mrueg in +* [FEATURE] Add new metric kube_job_status_suspended by @Indresh2410 in +* [FEATURE] Move endpoint ports into address metric by @mrueg in +* [ENHANCEMENT] Use concurrent map when storing metrics by @rarruda in + ## v2.13.0 / 2024-07-18 ### Note diff --git a/README.md b/README.md index d67173c677..0108cede90 100644 --- a/README.md +++ b/README.md @@ -79,11 +79,11 @@ Generally, it is recommended to use the latest release of kube-state-metrics. If | kube-state-metrics | Kubernetes client-go Version | |--------------------|:----------------------------:| -| **v2.9.2** | v1.26 | | **v2.10.1** | v1.27 | | **v2.11.0** | v1.28 | | **v2.12.0** | v1.29 | | **v2.13.0** | v1.30 | +| **v2.14.0** | v1.31 | | **main** | v1.31 | #### Resource group version compatibility @@ -96,8 +96,8 @@ release. The latest container image can be found at: -* `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0` (arch: `amd64`, `arm`, `arm64`, `ppc64le` and `s390x`) -* View all multi-architecture images at [here](https://explore.ggcr.dev/?image=registry.k8s.io%2Fkube-state-metrics%2Fkube-state-metrics:v2.13.0) +* `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0` (arch: `amd64`, `arm`, `arm64`, `ppc64le` and `s390x`) +* View all multi-architecture images at [here](https://explore.ggcr.dev/?image=registry.k8s.io%2Fkube-state-metrics%2Fkube-state-metrics:v2.14.0) ### Metrics Documentation diff --git a/data.yaml b/data.yaml index b20061e763..99eade51a7 100644 --- a/data.yaml +++ b/data.yaml @@ -1,12 +1,10 @@ # The purpose of this config is to keep all versions in a single file and make them machine accessible # Marks the latest release -version: "2.13.0" +version: "2.14.0" # List at max 5 releases here + the main branch compat: - - version: "v2.9.2" - kubernetes: "1.26" - version: "v2.10.1" kubernetes: "1.27" - version: "v2.11.0" @@ -15,5 +13,7 @@ compat: kubernetes: "1.29" - version: "v2.13.0" kubernetes: "1.30" + - version: "v2.14.0" + kubernetes: "1.31" - version: "main" kubernetes: "1.31" diff --git a/examples/autosharding/cluster-role-binding.yaml b/examples/autosharding/cluster-role-binding.yaml index 11cdc294a8..6d274aa826 100644 --- a/examples/autosharding/cluster-role-binding.yaml +++ b/examples/autosharding/cluster-role-binding.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics roleRef: apiGroup: rbac.authorization.k8s.io diff --git a/examples/autosharding/cluster-role.yaml b/examples/autosharding/cluster-role.yaml index d330803f9b..ed985f954a 100644 --- a/examples/autosharding/cluster-role.yaml +++ b/examples/autosharding/cluster-role.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics rules: - apiGroups: diff --git a/examples/autosharding/role-binding.yaml b/examples/autosharding/role-binding.yaml index a8bc73d9c1..f6057aa342 100644 --- a/examples/autosharding/role-binding.yaml +++ b/examples/autosharding/role-binding.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system roleRef: diff --git a/examples/autosharding/role.yaml b/examples/autosharding/role.yaml index 464e44658c..6259f5c729 100644 --- a/examples/autosharding/role.yaml +++ b/examples/autosharding/role.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system rules: diff --git a/examples/autosharding/service-account.yaml b/examples/autosharding/service-account.yaml index 8107dcf62c..9d19b1f173 100644 --- a/examples/autosharding/service-account.yaml +++ b/examples/autosharding/service-account.yaml @@ -5,6 +5,6 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system diff --git a/examples/autosharding/service.yaml b/examples/autosharding/service.yaml index f32d1001bb..cb00ae69cc 100644 --- a/examples/autosharding/service.yaml +++ b/examples/autosharding/service.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system spec: diff --git a/examples/autosharding/statefulset.yaml b/examples/autosharding/statefulset.yaml index a0ccaad8d2..11fa302193 100644 --- a/examples/autosharding/statefulset.yaml +++ b/examples/autosharding/statefulset.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system spec: @@ -18,7 +18,7 @@ spec: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 spec: automountServiceAccountToken: true containers: @@ -34,7 +34,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 + image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0 livenessProbe: httpGet: path: /livez diff --git a/examples/daemonsetsharding/cluster-role-binding.yaml b/examples/daemonsetsharding/cluster-role-binding.yaml index 11cdc294a8..6d274aa826 100644 --- a/examples/daemonsetsharding/cluster-role-binding.yaml +++ b/examples/daemonsetsharding/cluster-role-binding.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics roleRef: apiGroup: rbac.authorization.k8s.io diff --git a/examples/daemonsetsharding/cluster-role.yaml b/examples/daemonsetsharding/cluster-role.yaml index d330803f9b..ed985f954a 100644 --- a/examples/daemonsetsharding/cluster-role.yaml +++ b/examples/daemonsetsharding/cluster-role.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics rules: - apiGroups: diff --git a/examples/daemonsetsharding/daemonset-service.yaml b/examples/daemonsetsharding/daemonset-service.yaml index 82bbc568bb..b800c51b66 100644 --- a/examples/daemonsetsharding/daemonset-service.yaml +++ b/examples/daemonsetsharding/daemonset-service.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics-shard - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics-shard namespace: kube-system spec: diff --git a/examples/daemonsetsharding/daemonset.yaml b/examples/daemonsetsharding/daemonset.yaml index f0d78d6fd7..feb64691a7 100644 --- a/examples/daemonsetsharding/daemonset.yaml +++ b/examples/daemonsetsharding/daemonset.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics-shard - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics-shard namespace: kube-system spec: @@ -16,7 +16,7 @@ spec: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics-shard - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 spec: automountServiceAccountToken: true containers: @@ -29,7 +29,7 @@ spec: fieldRef: apiVersion: v1 fieldPath: spec.nodeName - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 + image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0 livenessProbe: httpGet: path: /livez diff --git a/examples/daemonsetsharding/deployment-service.yaml b/examples/daemonsetsharding/deployment-service.yaml index f32d1001bb..cb00ae69cc 100644 --- a/examples/daemonsetsharding/deployment-service.yaml +++ b/examples/daemonsetsharding/deployment-service.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system spec: diff --git a/examples/daemonsetsharding/deployment.yaml b/examples/daemonsetsharding/deployment.yaml index fcc95bceb5..e24d1d100b 100644 --- a/examples/daemonsetsharding/deployment.yaml +++ b/examples/daemonsetsharding/deployment.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system spec: @@ -17,13 +17,13 @@ spec: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 spec: automountServiceAccountToken: true containers: - args: - --resources=certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 + image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0 livenessProbe: httpGet: path: /livez diff --git a/examples/daemonsetsharding/service-account.yaml b/examples/daemonsetsharding/service-account.yaml index 8107dcf62c..9d19b1f173 100644 --- a/examples/daemonsetsharding/service-account.yaml +++ b/examples/daemonsetsharding/service-account.yaml @@ -5,6 +5,6 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system diff --git a/examples/standard/cluster-role-binding.yaml b/examples/standard/cluster-role-binding.yaml index 11cdc294a8..6d274aa826 100644 --- a/examples/standard/cluster-role-binding.yaml +++ b/examples/standard/cluster-role-binding.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics roleRef: apiGroup: rbac.authorization.k8s.io diff --git a/examples/standard/cluster-role.yaml b/examples/standard/cluster-role.yaml index d330803f9b..ed985f954a 100644 --- a/examples/standard/cluster-role.yaml +++ b/examples/standard/cluster-role.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics rules: - apiGroups: diff --git a/examples/standard/deployment.yaml b/examples/standard/deployment.yaml index 85539fc1d4..3666e8ab64 100644 --- a/examples/standard/deployment.yaml +++ b/examples/standard/deployment.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system spec: @@ -17,11 +17,11 @@ spec: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 spec: automountServiceAccountToken: true containers: - - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0 + - image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0 livenessProbe: httpGet: path: /livez diff --git a/examples/standard/service-account.yaml b/examples/standard/service-account.yaml index 8107dcf62c..9d19b1f173 100644 --- a/examples/standard/service-account.yaml +++ b/examples/standard/service-account.yaml @@ -5,6 +5,6 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system diff --git a/examples/standard/service.yaml b/examples/standard/service.yaml index f32d1001bb..cb00ae69cc 100644 --- a/examples/standard/service.yaml +++ b/examples/standard/service.yaml @@ -4,7 +4,7 @@ metadata: labels: app.kubernetes.io/component: exporter app.kubernetes.io/name: kube-state-metrics - app.kubernetes.io/version: 2.13.0 + app.kubernetes.io/version: 2.14.0 name: kube-state-metrics namespace: kube-system spec: