kube-state-metrics

kube-state-metrics/standalone

Kubernetes object state (restarts, readiness, resource limits) as Prometheus metrics

Deploys kube-state-metrics into the observability namespace of a local Kind cluster. It turns the state of pods, nodes and workloads into Prometheus metrics: container restarts and the reason for the last termination (OOMKilled), readiness, pod phase, and the resource requests and limits every container was given.

Pair it with a scrape of the kubelet (/metrics/resource, /metrics/cadvisor) for CPU and memory usage.

Install gck#

go install github.com/gravitee-io-labs/gck@latest

For other installation methods, see Installation .

Usage#

Create#

gck create --from kube-state-metrics/standalone

Cleanup#

gck delete

Quick Start#

Forward the metrics port to your host:

kubectl -n observability port-forward svc/kube-state-metrics 8080

Then, from another terminal, list container restarts:

curl -s localhost:8080/metrics | grep kube_pod_container_status_restarts_total

Composing with another stack#

To watch the pods of another stack, compose the abstract kube-state-metrics/base layer instead. It declares no cluster of its own, so the stack you compose it onto keeps naming the cluster:

gck create \
  --from gravitee-io/apim \
  --from kube-state-metrics/base

Point any scraper in the cluster at kube-state-metrics.observability.svc.cluster.local:8080.

Variables

Template variables overridable with --set. Use --set path.segments.var=value to target a specific context in the composition chain.

VariableDefaultOriginDescription
imageRepositoryregistry.k8s.io/kube-state-metrics/kube-state-metricskube-state-metrics/basekube-state-metrics Docker image repository
imageTagv2.20.0kube-state-metrics/basekube-state-metrics Docker image tag
namespaceobservabilitykube-state-metrics/baseNamespace kube-state-metrics is deployed into, shared with the rest of the observability layer so a collector or Prometheus there reaches it by service name
clusterNamekube-state-metricskube-state-metrics/standaloneName of the Kind cluster