kube-state-metrics

by joaquinito2051

Helm chartv7.3.0Apache-2.0

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-charts with chart kube-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:

  1. upgrade your existing release name using the new chart repository

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

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.

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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartkube-state-metrics is pinned at v7.3.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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