kube-state-metrics
by Prometheus
Install kube-state-metrics to generate and expose cluster-level metrics
About this chart
kube-state-metrics Helm Chart
Installs the kube-state-metrics agent.
Usage
The chart is distributed as an OCI Artifact as well as via a traditional Helm Repository.
- OCI Artifact:
oci://ghcr.io/prometheus-community/charts/kube-state-metrics - Helm Repository:
https://prometheus-community.github.io/helm-chartswith chartkube-state-metrics
The installation instructions use the OCI registry. Refer to the [helm repo](helm repo) command documentation for information on installing charts via the traditional repository.
Install Chart
helm install [RELEASE_NAME] oci://ghcr.io/prometheus-community/charts/kube-state-metrics [flags]
See configuration below.
See helm install for command documentation.
Uninstall Chart
helm uninstall [RELEASE_NAME]
This removes all the Kubernetes components associated with the chart and deletes the release.
See helm uninstall for command documentation.
Upgrading Chart
helm upgrade [RELEASE_NAME] oci://ghcr.io/prometheus-community/charts/kube-state-metrics [flags]
See helm upgrade for command documentation.
Migrating from stable/kube-state-metrics and kubernetes/kube-state-metrics
You can upgrade in-place:
- upgrade your existing release name using the new chart repository
Upgrading to v9.0.0
The default nodeSelector now includes kubernetes.io/os: linux to keep kube-state-metrics off Windows nodes in mixed clusters. This applies to both the Deployment and the autosharded StatefulSet and triggers a pod rollout on upgrade.
Helm merges custom nodeSelector labels with this default. Make sure the selected nodes are Linux nodes before upgrading. If you use a custom image for another OS, override nodeSelector.kubernetes.io/os. Set nodeSelector: null to remove the selector entirely.
Upgrading to v8.0.0
This version drops support for configuring CiliumNetworkPolicy as it is a vendor specific resource.
In addition, the networkPolicy.flavor setting is no longer persistent and can be safely dropped as only Kubernetes NetworkPolicy resources are supported.
Upgrading to v6.0.0
This version drops support for deprecated Pod Security Policy resources.
Upgrading to v3.0.0
v3.0.0 includes kube-state-metrics v2.0, see the changelog for major changes on the application-side.
The upgraded chart now the following changes:
- Dropped support for helm v2 (helm v3 or later is required)
- collectors key was renamed to resources
- namespace key was renamed to namespaces
Configuration
See Customizing the Chart Before Installing. To see all configurable options with detailed comments:
helm show values oci://ghcr.io/prometheus-community/charts/kube-state-metrics
Admission policy collectors
kube-state-metrics v2.20.0 and later supports the following admission policy collectors.
They use the admissionregistration.k8s.io/v1 API and are opt-in in this chart to preserve compatibility with older Kubernetes versions and image overrides.
| Collectors | Required Kubernetes version |
|---|---|
validatingadmissionpolicies, validatingadmissionpolicybindings | v1.30 or later |
mutatingadmissionpolicies, mutatingadmissionpolicybindings | v1.36 or later |
Enable only the collectors supported by your cluster through collectorsExtra or collectors.
For example, on Kubernetes v1.36 or later:
collectorsExtra:
- mutatingadmissionpolicies
- mutatingadmissionpolicybindings
- validatingadmissionpolicies
- validatingadmissionpolicybindings
On Kubernetes v1.30 through v1.35, enable only the two validating admission policy collectors. Do not enable these collectors when overriding the image to a kube-state-metrics version older than v2.20.0.
These resources are cluster-scoped and require cluster-wide RBAC permissions.
With the default RBAC settings, the chart adds list and watch permissions only for the selected collectors.
If you manage RBAC separately, grant those permissions on the selected resources in the admissionregistration.k8s.io API group.
kube-rbac-proxy
You can enable kube-state-metrics endpoint protection using kube-rbac-proxy. By setting kubeRBACProxy.enabled: true, this chart will deploy one RBAC proxy container per endpoint (metrics & telemetry).
To authorize access, authenticate your requests (via a ServiceAccount for example) with a ClusterRole attached such as:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kube-state-metrics-read
rules:
- apiGroups: [ "" ]
resources: ["services/kube-state-metrics"]
verbs:
- get
See kube-rbac-proxy examples for more details.
auth-filter
As an alternative to kube-rbac-proxy, kube-state-metrics can authenticate and authorize requests itself using its built-in --auth-filter. Set authFilter.enabled: true to add the --auth-filter flag and the create permissions on tokenreviews and subjectaccessreviews that the filter requires.
Scrapers must then authenticate (for example via a ServiceAccount token) and be authorized to get the kube-state-metrics service. See the upstream Authentication / Authorization documentation for the scraper-side ClusterRole and ClusterRoleBinding.
Deploy kube-state-metrics with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kube-state-metrics on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartkube-state-metrics is pinned at v9.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply