skip to content
Adiatma Blog's

Setup Kubernetes Metrics Server

/ 1 min read

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

Installation

Terminal window
# add helm repo
helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
# install
helm upgrade --install metrics-server metrics-server/metrics-server \
--create-namespace --namespace metrics-server

Install metrics-server in namespaces metrics-server.

Validate and check apiservices

Terminal window
kubectl get apiservices | grep metrics
v1beta1.metrics.k8s.io metrics-server/metrics-server False

Wait until metrics-server/metrics-server changes to True

Usage

Terminal window
# check node resources
kubectl top nodes
# check pod resources
kubectl top pods

In real cases metrics server help you to enable HPA or VPA (Vertical Pod Autoscalling) to make informed decissions.