From 7de70ac2fc64a03698f131c883474da73945620a Mon Sep 17 00:00:00 2001 From: ZverGuy Date: Wed, 4 Nov 2026 04:11:15 +0700 Subject: [PATCH] feat(monitoring-agents): export PVC labels from kube-state-metrics The tenant metrics API scopes a query to one application by looking up its pods and PVCs through their apps.cozystack.io/application.* lineage labels. kube-state-metrics emits kube_persistentvolumeclaim_labels only for resources on --metric-labels-allowlist, so without PVCs there the PVC half of that lookup always comes back empty and volume series of an application fall out of its scope. All labels are allowed, as for pods and deployments: kube-state-metrics emits one series per PVC whatever keys are listed, and PVCs are far fewer than pods, which already export every label. Assisted-by: LLM Signed-off-by: ZverGuy --- .../tests/kube_state_metrics_labels_test.yaml | 15 +++++++++++++++ packages/system/monitoring-agents/values.yaml | 14 ++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 packages/system/monitoring-agents/tests/kube_state_metrics_labels_test.yaml diff --git a/packages/system/monitoring-agents/tests/kube_state_metrics_labels_test.yaml b/packages/system/monitoring-agents/tests/kube_state_metrics_labels_test.yaml new file mode 100644 index 000000000..578371a1e --- /dev/null +++ b/packages/system/monitoring-agents/tests/kube_state_metrics_labels_test.yaml @@ -0,0 +1,15 @@ +suite: kube-state-metrics exports the labels of pods, deployments and PVCs +# The tenant metrics API scopes a query to one application by looking up the +# application's pods and PVCs in kube_pod_labels and +# kube_persistentvolumeclaim_labels by their apps.cozystack.io/application.* +# lineage labels. kube-state-metrics emits no kube_*_labels series at all for +# a resource missing from this allowlist, so dropping persistentvolumeclaims +# silently empties the PVC branch of that lookup. +templates: + - charts/kube-state-metrics/templates/deployment.yaml +tests: + - it: allowlists all labels of pods, deployments and persistentvolumeclaims + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: --metric-labels-allowlist=pods=[*],deployments=[*],persistentvolumeclaims=[*] diff --git a/packages/system/monitoring-agents/values.yaml b/packages/system/monitoring-agents/values.yaml index a9c22cb14..84c39ce44 100644 --- a/packages/system/monitoring-agents/values.yaml +++ b/packages/system/monitoring-agents/values.yaml @@ -6,9 +6,10 @@ kube-state-metrics: # 322 pods and roughly 25.6k series, which is the smallest cluster we run. The # request sits above the 176Mi mean rather than at the peak, and the limit # carries wide headroom on purpose: this component's memory scales with the - # number of objects in the cluster, and --metric-labels-allowlist below widens - # every pod and deployment series further, so a cluster larger than the one - # measured will land well above the peak seen here. + # number of objects in the cluster, and --metric-labels-allowlist below copies + # every label of each pod, deployment and PVC onto its kube_*_labels series, + # so a cluster larger than the one measured will land well above the peak + # seen here. # 2Gi is 6.7x that peak, so scaling linearly with object count it stays a # ceiling rather than a bound up to roughly 2100 pods and 170k series. # @@ -27,7 +28,12 @@ kube-state-metrics: limits: memory: 2Gi extraArgs: - - --metric-labels-allowlist=pods=[*],deployments=[*] + # PVCs are listed so the tenant metrics API can find an application's PVCs + # in kube_persistentvolumeclaim_labels by their apps.cozystack.io/application.* + # lineage labels. kube-state-metrics emits that metric only for resources on + # this list, one series per PVC; naming only the lineage keys would emit the + # same number of series. + - --metric-labels-allowlist=pods=[*],deployments=[*],persistentvolumeclaims=[*] rbac: extraRules: - apiGroups: