From 8d5c6d9fe0b4c2907f4a342ca0f619109c529f65 Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Thu, 13 Jun 2024 11:25:37 -0400 Subject: [PATCH] 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 cd7ef8d73e..8a7b154a66 100644 --- a/README.md +++ b/README.md @@ -280,7 +280,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 @@ -293,7 +293,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 4cdcd6637c..005b88b97b 100644 --- a/README.md.tpl +++ b/README.md.tpl @@ -281,7 +281,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 @@ -294,7 +294,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 3f73e49854..3a54f4d445 100644 --- a/docs/developer/cli-arguments.md +++ b/docs/developer/cli-arguments.md @@ -46,7 +46,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 73a0c01dfd..a422467bd5 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.12.0 livenessProbe: httpGet: diff --git a/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet b/jsonnet/kube-state-metrics/kube-state-metrics.libsonnet index a5de0d9718..22c4b6667d 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 1ad8207f89..dc295b1ebe 100644 --- a/pkg/app/server.go +++ b/pkg/app/server.go @@ -205,7 +205,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 ac2ae45d99..c5c186301b 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -46,7 +46,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"` @@ -121,7 +121,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