Overview
The metrics server is a key component in Kubernetes used for collecting and aggregating metrics such as CPU and memory usage from nodes and pods. These metrics are essentials for monitoring, scalling, and ensuring the health of Kubernetes clusters.
- The metrics server collects resource usage metrics (e.g, CPU and memory) from the Kubelets running on each node.
- It aggregates these metrics and makes them available via the Kubernetes API, enabling components like the Horizontal Pod Autoscalling (HPA) to make informed decissions.
Getting Started
Pre-requisites
- Install
helm
https://helm.sh/docs/intro/install/
Installation
# add helm repohelm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/# installhelm upgrade --install metrics-server metrics-server/metrics-server \--create-namespace --namespace metrics-server
Install metrics-server in namespaces metrics-server
.
Validate and check apiservices
kubectl get apiservices | grep metricsv1beta1.metrics.k8s.io metrics-server/metrics-server False
Wait until metrics-server/metrics-server changes to True
Usage
# check node resourceskubectl top nodes# check pod resourceskubectl top pods
In real cases metrics server help you to enable HPA or VPA (Vertical Pod Autoscalling) to make informed decissions.