In this blog we will see how to install Metrics-Server in kubernetes cluster  to check the resources usage of node and pods.

Metrics Server collects resource metrics of Nodes,Pods from Kubelets and exposes them in Kubernetes apiserver through Metrics API.

Requirements:

1.Kubernetes cluster

Step 1:

Deploy Metrics server in kubernetes cluster,

Login to kubernetes cluster and execute below command,

# kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml


Then verify the pod status,

# kubectl get pods -n kube-system|grep metrics

If the pod is not running follow step 2 or else go to step 3.


Step 2 : 

When I see the pod is not running and went to CrashLoopBackOff status,


And I have seen below error in the metrics server pod,


To avoid this issue we need to add below parameters in the metrics deployment,

Edit the deployment by,

# kubectl edit deploy -n kube-system metrics-server

Then add below args under spec.template.spec.containers,

args:
- --kubelet-insecure-tls
- --metric-resolution=30s



Then add "hostNetwork: true" under spec.template.spec,


Now save the changes and check the pod status now,

# kubectl get pods -n kube-system|grep metrics


This time it is running fine.

Step 3:

Check the resources status,

To check the resource usage status for all nodes,

# kubectl top nodes


To check the resource usage status for all pods,

# kubectl top pods


That's all, We have deployed metrics server in kubernetes cluster and checked the resource usage status for all Nodes and pods.

Post a Comment

Previous Post Next Post