Cyberithub

How to Deploy Metrics Server on a Kubernetes Cluster [Step by Step]

Advertisements

In this article I will take you through a step by step guide to deploy metrics server. According to Github, Metrics Server is a scalable, efficient source of container resource metrics for Kubernetes built-in autoscaling pipelines. Metrics Server collects resource metrics from Kubelets and exposes them in Kubernetes apiserver through Metrics API for use by Horizontal Pod Autoscaler and Vertical Pod Autoscaler. Metrics API can also be accessed by kubectl top, making it easier to debug autoscaling pipelines.

Features of Metric Server

Metrics Server offers following :-

Advertisements
  • A single deployment that works on most clusters.
  • Fast autoscaling, collecting metrics every 15 seconds.
  • Resource efficiency, using 1 mili core of CPU and 2 MB of memory for each node in a cluster.
  • Scalable support up to 5,000 node clusters.

How to Deploy Metrics Server on a Kubernetes Cluster [Step by Step]

How to Deploy Metrics Server on a Kubernetes Cluster

Also Read: How to Quickly Deploy Kubernetes Cluster Using Vagrant in 7 Simple Steps

Step 1: Deploy Metrics Server

To deploy metrics server in your Kubernetes cluster, you need to run below kubectl apply command. This will create a metrics-server deployment under kube-system namespace.

Advertisements
root@cyberithub:~# kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
serviceaccount/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
service/metrics-server created
deployment.apps/metrics-server created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created

 

Step 2: Verify Metrics Server

Once the deployment is created, you can verify this by using kubectl get deployment metrics-server -n kube-system command as shown below.

root@cyberithub:~# kubectl get deployment metrics-server -n kube-system
NAME           READY UP-TO-DATE AVAILABLE AGE
metrics-server 0/1    1          0        28s

 

Step 3: Check Node Utilization

It is now time to verify the metrics collected by the metrics-server. You can check the node utilization by using kubectl top node command.

Advertisements
root@cyberithub:~# kubectl top node
NAME         CPU(cores) CPU% MEMORY(bytes) MEMORY%
node-1       356m        0%   1291Mi        0%
node-2       73m         0%   369Mi         0%

 

Step 4: Check Pod Utilization

Similarly, if you want to check the pod metrics then you need to use kubectl top pods command as shown below.

root@cyberithub:~# kubectl top pods
NAME       CPU(cores) MEMORY(bytes)
example-1  20m        32Mi
example-2  1m         18Mi
example-3  140m       252Mi

Leave a Comment