Andrea Casarin

Andrea Casarin

Published on: 12/10/2022, 10:22:38 AM - Reading time: 1 minute

Kubernetes state and metrics monitoring

When moving your workload from some VMs to a Kubernetes cluster you may find yourself losing grasp on what's happening, it happens to all of us.

However K8S has some great ways to make sure you are on top of your cluster status, you just have to make sure you setup them right.

metrics-server

Gets resource metrics from Kubelets and exposes them through the Kubernetes Api Server via Metrics API, think at them as:

  • CPU
  • memory
  • network usage

Used primarly for horizontal and vertical autoscaling, accessed via console with kubectl top.

kube-state-metrics

Gets metrics from Kubernetes Api Server end generates metrics about in cluster objects, think at them as:

  • Resource requests and limits
  • Number of objects–nodes, pods, namespaces, services, deployments
  • Number of pods in a running/terminated/failed state

Used primarly as a data source for monitoring.

So what?

You may want to use both to gain observability over the cluster using some sort of service to aggregate and store those metrics then visualize in a user friendly way.

My current preferred way is via Prometheus + Grafana, or NewRelic to combine even more data (eg. logs).