Skip to content

Commit 85f8a2c

Browse files
rename to --enable-unscheduled-pods-fetching
1 parent 49e1170 commit 85f8a2c

File tree

9 files changed

+19
-11
lines changed

9 files changed

+19
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ spec:
282282
fieldPath: spec.nodeName
283283
```
284284

285-
To track metrics for unassigned pods, you need to add an additional deployment and set `--fetch-unscheduled-pods`, as shown in the following example:
285+
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:
286286

287287
```
288288
apiVersion: apps/v1
@@ -295,7 +295,7 @@ spec:
295295
name: kube-state-metrics
296296
args:
297297
- --resources=pods
298-
- --fetch-unscheduled-pods
298+
- --enable-unscheduled-pods-fetching
299299
```
300300

301301
Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding).

README.md.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ spec:
283283
fieldPath: spec.nodeName
284284
```
285285

286-
To track metrics for unassigned pods, you need to add an additional deployment and set `--fetch-unscheduled-pods`, as shown in the following example:
286+
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:
287287

288288
```
289289
apiVersion: apps/v1
@@ -296,7 +296,7 @@ spec:
296296
name: kube-state-metrics
297297
args:
298298
- --resources=pods
299-
- --fetch-unscheduled-pods
299+
- --enable-unscheduled-pods-fetching
300300
```
301301

302302
Other metrics can be sharded via [Horizontal sharding](#horizontal-sharding).

docs/developer/cli-arguments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Flags:
4848
--custom-resource-state-config-file string Path to a Custom Resource State Metrics config file (experimental)
4949
--custom-resource-state-only Only provide Custom Resource State metrics (experimental)
5050
--enable-gzip-encoding Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.
51-
--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.
51+
--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.
5252
-h, --help Print Help text
5353
--host string Host to expose metrics on. (default "::")
5454
--kubeconfig string Absolute path to the kubeconfig file

examples/daemonsetsharding/deployment-no-node-pods.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
containers:
2424
- args:
2525
- --resources=pods
26-
- --fetch-unscheduled-pods
26+
- --enable-unscheduled-pods-fetching
2727
image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.13.0
2828
livenessProbe:
2929
httpGet:

jsonnet/kube-state-metrics/kube-state-metrics.libsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@
377377
local c = ksm.deployment.spec.template.spec.containers[0] {
378378
args: [
379379
'--resources=pods',
380-
'--fetch-unscheduled-pods',
380+
'--enable-unscheduled-pods-fetching',
381381
],
382382
name: shardksmname,
383383
};
@@ -410,7 +410,7 @@
410410
local c = ksm.deployment.spec.template.spec.containers[0] {
411411
args: [
412412
'--resources=pods',
413-
'--fetch-unscheduled-pods',
413+
'--enable-unscheduled-pods-fetching',
414414
],
415415
};
416416
local shardksmname = ksm.name + "-no-node-pods";

pkg/app/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func RunKubeStateMetrics(ctx context.Context, opts *options.Options) error {
224224

225225
namespaces := opts.Namespaces.GetNamespaces()
226226
nsFieldSelector := namespaces.GetExcludeNSFieldSelector(opts.NamespacesDenylist)
227-
nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.FetchUnscheduledPods)
227+
nodeFieldSelector := opts.Node.GetNodeFieldSelector(opts.EnableUnscheduledPodsFetching)
228228
merged, err := storeBuilder.MergeFieldSelectors([]string{nsFieldSelector, nodeFieldSelector})
229229
if err != nil {
230230
return err

pkg/options/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type Options struct {
5959
Namespaces NamespaceList `yaml:"namespaces"`
6060
NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"`
6161
Node NodeType `yaml:"node"`
62-
FetchUnscheduledPods bool `yaml:"fetch_unscheduled_pods"`
62+
EnableUnscheduledPodsFetching bool `yaml:"enable_unscheduled_pods_fetching"`
6363
Pod string `yaml:"pod"`
6464
Port int `yaml:"port"`
6565
Resources ResourceSet `yaml:"resources"`
@@ -138,7 +138,7 @@ func (o *Options) AddFlags(cmd *cobra.Command) {
138138

139139
o.cmd.Flags().BoolVar(&o.CustomResourcesOnly, "custom-resource-state-only", false, "Only provide Custom Resource State metrics (experimental)")
140140
o.cmd.Flags().BoolVar(&o.EnableGZIPEncoding, "enable-gzip-encoding", false, "Gzip responses when requested by clients via 'Accept-Encoding: gzip' header.")
141-
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.")
141+
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.")
142142
o.cmd.Flags().BoolVarP(&o.Help, "help", "h", false, "Print Help text")
143143
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.")
144144
o.cmd.Flags().Int32Var(&o.Shard, "shard", int32(0), "The instances shard nominal (zero indexed) within the total number of shards. (default 0)")

pkg/options/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ type NodeType string
110110
// GetNodeFieldSelector returns a nodename field selector.
111111
func (n *NodeType) GetNodeFieldSelector(noNodeAssigned bool) string {
112112
if noNodeAssigned {
113+
if string(*n) != "" {
114+
klog.Warningf("spec.nodeName=%s will not be used, because --enable-unscheduled-pods-fetching is set", string(*n))
115+
}
113116
klog.InfoS("Using spec.nodeName= to select unscheduable pods without node")
114117
return "spec.nodeName="
115118
}

pkg/options/types_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ func TestNodeFieldSelector(t *testing.T) {
190190
Node: "",
191191
Wanted: "spec.nodeName=",
192192
},
193+
{
194+
Desc: "have node name when --enable-unscheduled-pods-fetching is set",
195+
Node: "",
196+
Wanted: "spec.nodeName=",
197+
},
193198
}
194199
for _, test := range tests1 {
195200
node := test.Node

0 commit comments

Comments
 (0)