Skip to main content
In this guide, we will explore how to monitor Kubernetes cluster components using the Metrics Server. We’ll walk through inspecting running pods, deploying the Metrics Server, and examining resource consumption on both nodes and pods.

Inspecting Running Pods

Before setting up monitoring, verify that your workloads are running correctly by listing the pods:
You should see output similar to this:
After a short wait, the rabbit pod should transition to a running state:

Deploying the Metrics Server

To monitor resource consumption, you need to deploy the Kubernetes Metrics Server. In this lab, we use a preconfigured repository with the required settings.
For production environments, avoid using these lab-specific configurations. Always refer to the official Metrics Server documentation for accurate and secure deployment.

Step 1: Clone the Repository

Clone the repository that includes the metrics server configuration:
The output should be similar to:

Step 2: Examine the Configuration Files

Navigate to the repository directory and list its contents to review the configuration files:
Expected output:

Step 3: Deploy the Metrics Server

Deploy all required objects with the following command:
This command should produce output confirming that resources have been successfully created, for example:
It may take a few minutes for the Metrics Server to begin gathering and reporting resource data.

Verifying Metrics and Analyzing Resource Consumption

Once the Metrics Server is up and running, you can verify the resource usage on your nodes and pods.

Checking Node Metrics

To check the CPU and memory usage for each node, run:
Sample output:

Checking Pod Metrics

To list the resource usage for individual pods, execute:
Expected output:

Analyzing the Data

After gathering metrics, you can analyze them to understand resource consumption patterns across your cluster.

Identifying the Node with the Highest CPU Usage

Review the node metrics—for example:
The control plane node consumes significantly more CPU compared to node01 due to its hosting of various control components.

Identifying the Node with the Highest Memory Usage

Using the node metrics:
It’s evident that the control plane node is also consuming more memory.

Determining the Pod Using the Most Memory

Analyze the pod metrics to pinpoint the pod consuming the most memory:
The rabbit pod is using the most memory (252Mi), indicating that its workload—possibly RabbitMQ—may require higher resource allocation.

Identifying the Pod with the Least CPU Usage

From the pod metrics, notice that certain pods consistently consume minimal CPU (around 1m), suggesting low processing requirements for those workloads.

Conclusion

In this guide, you learned how to:
  1. Inspect running pods to ensure your workloads are active.
  2. Deploy the Kubernetes Metrics Server using a preconfigured repository.
  3. Verify and analyze resource usage on both nodes and pods within your cluster.
This foundational demonstration helps you monitor cluster components effectively, empowering you to identify areas with high resource consumption and optimize performance in your Kubernetes environment. Happy monitoring!

Watch Video