State Metrics 簡介與設置

What is Kube State Metrics?

  • a service that talks to the Kubernetes API server to get all the details about all the API objects like deployments, pods, daemonsets, Statefulsets, etc.
  • Kube state metrics service exposes all the metrics on /metrics URI. Prometheus can scrape all the metrics exposed by Kube state metrics.
 
 

Important metrics you can get from Kube state metrics.

  1. Node status, node capacity (CPU and memory)
  1. Replica-set compliance (desired/available/unavailable/updated status of replicas per deployment)
  1. Pod status (waiting, running, ready, etc)
  1. Ingress metrics
  1. PV, PVC metrics
  1. Daemonset & Statefulset metrics.
  1. Resource requests and limits.
  1. Job & Cronjob metrics
 
 
 

Kube State Metrics Setup

Step 1: Clone the Github repo

git clone https://github.com/devopscube/kube-state-metrics-configs.git

Step 2: Create all the objects by pointing to the cloned directory.

microk8s kubectl apply -f kube-state-metrics-configs/

Step 3: Check the deployment status using the following command.

microk8s kubectl get deployments kube-state-metrics -n kube-system
 
再來就可以來看 Grafana 的設置了!