How to configure metrics-server to monitor kubernetes cluster resources ?

For any virtualization or cloud platform, resource monitoring is a critical operational component. And its applicable for Kubernetes platform as well. As documented in Tools for Monitoring Resources, a lightweight, short-term, in-memory tool called metrics-server cab be used to collect the CPU & Memory utilization of nodes and pods in a kubernetes cluster.

The configuration of metrics-server is really simple and can be deployed easily on the kubernetes-master node. Refer the following steps to configure the metrics-server on an existing kubernetes cluster:


a. We have a 3 node cluster already deployed and ready for the configuration.

   
     

b. Login to the k8s-master node and get the components.yaml file from the latest release. While writing this document, the latest release is v0.4.2

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

c. Open the file and go to the containers argument section:

 

d. Include the following line as marked below and save the file:

     

e. Now the deployment file is ready for the deployment. Use the below command to deploy it:

  # kubectl apply -f  components.yaml

f. If anything will be available, it wont change and new components will be created:

     

g. Once deployment is complete, you can see the deployment, service and pods as mentioned below:

 

h. If you will check for the apiservices, you should be able to see a new entry there too which is running in the kube-system namespace:

     

Now it will take just few seconds to collect the nodes and pods resource utilization details. And you should be able to query the resource details using the following commands:

a. To get the node's resource utilization, use the below command:

     

b. To get the pod's resource utilization, use the below command:

     

    You can filter the namespace based resource utilization using specific flags as mentioned above.

c. To check how many containers are running in a pod, use the below command:

     

    Now as highlighted above, there is a pod in the kube-system namespace that's having two containers in it. If you want to check the resource utilization of both the containers in that pod, use the below command as shown:

     

    The command line tool is having some limitations and monitoring the resources beyond this out of scope at this point of time. That's why a better way to monitor the container level resource utilization is using Prometheus. Its a community driven opensource monitoring tool with much better monitoring capabilities. Refer the architecture documents to know more about it.

Comments

Popular posts from this blog

VNC Configuration using Ansible in CentOS 7

How to build Ubuntu Server 20.04 LTS OVA with vAPP Properties ?

LVM Configuration using Ansible in CentOS 7