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.
| Variable | Default | Origin | Description |
|---|---|---|---|
imageRepository | registry.k8s.io/kube-state-metrics/kube-state-metrics | kube-state-metrics/base | kube-state-metrics Docker image repository |
imageTag | v2.20.0 | kube-state-metrics/base | kube-state-metrics Docker image tag |
namespace | observability | kube-state-metrics/base | Namespace 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 |
clusterName | kube-state-metrics | kube-state-metrics/standalone | Name of the Kind cluster |