Metrics-Server in Kubernetes ☸☸

How to deploy k8s metrics server and use it for monitoring

Vibhor Chinda
Google Cloud - Community
5 min readJul 23, 2023

--

Introduction 🚩🚩

Hi fellow Readers 👋 :))
It has been long since I wrote something but I feel it’s always better to restart positive habits even if we feel it’s too late than never.
Currently I am trying to be better with cloud native technologies and stuff.

In my previous articles, I have heavily shared my knowledge about Kubernetes. Continuing on those lines, Today I will be again writing about another major concept which is being widely used in the world of Kubernetes. This article is about the usage of Metrics-Server in Kubernetes which helps to monitor your Kubernetes cluster.

Monitoring your Kubernetes cluster can give you insights to better manage your cluster. Hence it is an important concept to know 😎

So In this article, we will try to learn :

  • What is a Kubernetes Metrics Server ?
  • How to setup the Metrics Server
  • Monitoring the cluster using Metrics Server

Before starting with this Article.
I just wanna say that if you have been following me in my Technical Journey and if you like my writings and want to read more from me in the future :))
Please Do clap and follow me 🙈.

Plus In case of any doubts around this article or for some general chit chat, feel free to reach out to me on my social media handles😃.

Twitterhttps://twitter.com/ChindaVibhor

LinkedInhttps://www.linkedin.com/in/vibhor-chinda-465927169

It will be a small but an extremely interesting article.
So without any further delay, lets get started with it 🐵

What is a Kubernetes Metrics Server ?

The Kubernetes Metrics Server is a resource metrics monitoring tool for Kubernetes. The Kubernetes Metrics Server measures CPU and memory usage across the Kubernetes cluster. This metrics-server collects metrics and then shows resource usage statistics for your cluster so that you can monitor resource usage for each node and also for each pod.

You can monitor your resource usage with simple commands using the top command like kubectl top pods and kubectl top nodes.

How to setup the Metrics Server 😐😐

Photo by Clément Hélardot on Unsplash
  • Setting up Kubernetes Local Cluster :

In this tutorial, I will use Minikube which is a tool to run a Kubernetes cluster locally. Steps to create a local Kubernetes cluster using Minikube is already discussed in one of my previous articles. Refer the below attached article to complete the setup.

Now when our cluster is up and ready, lets move forward to the next ⛅️

  • Installing the Metrics Server

The k8s metrics server is not installed by default in your Kubernetes cluster. One has to install it on thier own.
It can be done using the below commands :

For Kubernetes version 1.21+:

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/high-availability-1.21+.yaml​

For Kubernetes version 1.19–1.21:

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/high-availability

After running the above commands. Deployment named “metrics-server” will be created in the namespace “kube-system”.

Use the below command to see the deployment :

Kubectl get deployments -n=kube-system

**Note: One needs to edit the above created deployment and put a flag under the args section to make the things working.

Use the below command to edit the deployment :

Kubectl edit deployment -n=kube-system metrics-server

Put the follow flag “ — — kubelet-insecure-tls=true” under the args section of the deployment like this :

Hurray !! Metrics Server is now setup completely and is ready to use.
Lets move to next section, where we will use metrics server to monitor the local K8s cluster we created.😏 ⛅️

Monitoring the cluster using Metrics Server

Photo by Joshua Aragon on Unsplash

To monitor your cluster components or to get the stats about your resources, you just need to run these commands.

To monitor the resources of your nodes:

kubectl top nodes

To monitor the resource of your pods:

kubectl top pods

What next ?? 👀 👀

Thanks a lot for reaching till here! This is the end of this article.
But we have only scratched the surface of the K8s ecosystem :))
Much more to go, it will be a fun journey where we will learn a lot of cool stuff together. 🚀 🚀

Taking it just one article at a time 😁
Do clap and follow me 🙈 if you like my writings and want to read more from me in the future :))

In case of any doubts around this article or for some general chit chat, feel free to reach out to me on my social media handles

Twitter — https://twitter.com/ChindaVibhor

LinkedIn — https://www.linkedin.com/in/vibhor-chinda-465927169/

Previous Articles :

I will still keep on coming with new articles covering a bunch of topics I am exploring.

That’s All folks !! Doodles :))

--

--

Vibhor Chinda
Google Cloud - Community

Software Developer 2 @Guidewire | Ex - VMware | CKA | Exploring Cloud Tech | Developing Patience ✨✨