204 words
1 minutes
Metrics server setup in kubernetes

Introduction#

This article explains method of installing the helm chart metrics-server in kubernetes cluster. Also, it shows how to use different commands to see metrics details from cluster.

The metrics server collects metrics from Kubelets and exposes them in Kubernetes apiserver through Metrics API.

Install Metrics Server#

Add helm repository and update charts.

helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
helm repo update

Install metrics-server chart.

helm upgrade --install metrics-server metrics-server/metrics-server \
  --namespace kube-system

The above steps install metrics server in kubernetes cluster, however in local cluster for example cluster created by kind need extra argument to support without CA verification. Following command can be used to install metrics server in kind local kubernetes cluster.

helm upgrade --install metrics-server metrics-server/metrics-server \
  --namespace kube-system --set 'args[0]=--kubelet-insecure-tls'

Useful Commands#

Once Metrics Server is installed in the cluster, we can fetch metrics like current CPU and memory utilization from the Metrics API by using kubectl top command.

View top nodes#

Following command to display resource usage of all cluster nodes.

kubectl top nodes

View top pods#

Following command to display resource usage of pods for specified namespace.

kubectl top pod --namespace <namespace>

View top containers#

Following command to display resource usage of containers for specified namespace and pod.

kubectl top pod <pod> --namespace <namespace> --containers

View node details#

Following command to display resource usage for specified node

kubectl describe node <node>

References#

Metrics server setup in kubernetes
https://semusings.dev/posts/2022/2022-06-01-metrics-server-setup-in-kubernetes/
Author
Bhuwan Prasad Upadhyay
Published at
2022-06-01