Description
What happened:
I tried using --labels-metric-allow-list
flag to enable labels in kube_node_labels
metric. Depending on quotation markings results were different (described below).
All deployments were made with following cli arguments, only last line was changed in test cases:
spec:
containers:
- args:
- --host=127.0.0.1
- --port=8080
- --telemetry-host=127.0.0.1
- --telemetry-port=8081
- --pod=$(POD_NAME)
- --pod-namespace=$(POD_NAMESPACE)
- --labels-metric-allow-list="nodes=["kubernetes.io/arch","gpu.infra/intel","network.infra/fast"]"
Test cases tried on a cluster:
- all quoted
yaml line: - '--labels-metric-allow-list="nodes=["kubernetes.io/arch","gpu.infra/intel","network.infra/fast"]"'
ksm status: did not start
ksm logs:
invalid argument "\"nodes=[\"kubernetes.io/arch\",\"gpu.infra/intel\",\"network.infra/fast\"]\"" for "--labels-metric-allow-list" flag: invalid format, metric=[label1,label2,labeln...],metricN=[]
- quoted labels only
yaml line: - --labels-metric-allow-list=nodes=["kubernetes.io/arch","gpu.infra/intel","network.infra/fast"]
ksm status: ksm started
metric output: kube_node_labels{container="kube-rbac-proxy-main", instance="10.42.5.210:8443", job="kube-state-metrics", node="node01"}
- quoted all parameters to cli option
yaml line: - --labels-metric-allow-list="nodes=["kubernetes.io/arch","gpu.infra/intel","network.infra/fast"]"
ksm status: did not start
ksm logs:
invalid argument "\"nodes=[\"kubernetes.io/arch\",\"gpu.infra/intel\",\"network.infra/fast\"]\"" for "--labels-metric-allow-list" flag: invalid format, metric=[label1,label2,labeln...],metricN=[]
- quoted array, but not labels
yaml line: - --labels-metric-allow-list="nodes=[kubernetes.io/arch,gpu.infra/intel,network.infra/fast]"
ksm status: did not start
ksm logs:
invalid argument "\"nodes=[kubernetes.io/arch,gpu.infra/intel,network.infra/fast]\"" for "--labels-metric-allow-list" flag: invalid format, metric=[label1,label2,labeln...],metricN=[]
- no quotes
yaml line: - --labels-metric-allow-list=nodes=[kubernetes.io/arch,gpu.infra/intel,network.infra/fast]
ksm status: started
metric output: kube_node_labels{container="kube-rbac-proxy-main", instance="10.42.5.202:8443", job="kube-state-metrics", label_gpu_infra_intel="true", label_kubernetes_io_arch="amd64", label_network_infra_fast="true", node="node01"}
What you expected to happen:
kube_node_labels
have additional labels and quotation marks don't affect ksm operations.
At a minimum, I would expect test case #5 and #2 to produce the same outcome.
How to reproduce it (as minimally and precisely as possible):
Deploy KSM to k8s environment. The problem doesn't occur when starting KSM from the command line
Anything else we need to know?:
Environment:
- kube-state-metrics version: 2.0.0-alpha.3
- Kubernetes version (use
kubectl version
): 1.19.4 - Cloud provider or hardware configuration: k3s
- Other info: Manifests used for ksm deployment are public and available at https://github.com/thaum-xyz/ankhmorpork/tree/master/apps/monitoring/ksm. Commit with all test cases is available at thaum-xyz/ankhmorpork@1c5be5d