DEV Community

Dmitry Romanoff
Dmitry Romanoff

Posted on

How to check the memory usage of a pod in Kubernetes?

To check the memory usage of a pod in Kubernetes, you can use the kubectl top command.

Step 1: Open a terminal window and ensure that you are logged in to the Kubernetes cluster where the pod is running.

Step 2: Run the following command to get the name of the pod:

kubectl get pods

This command will show you a list of all the pods running in the cluster. Find the name of the pod that you want to check the memory usage for.

Step 3: Run the following command to check the memory usage of the pod:

kubectl top pod <pod-name> --containers

Replace with the name of the pod that you want to check the memory usage for.

This command will show you the memory usage of each container running in the pod, in bytes.

Alternatively, you can use the kubectl describe command to get more detailed information about the pod, including its memory usage.

Here are the steps:

Step 1: Run the following command to get detailed information about the pod:

kubectl describe pod <pod-name>

Replace with the name of the pod that you want to check the memory usage for.

This command will show you a detailed description of the pod, including its memory usage.

Step 2: Look for the Containers section in the output. Under each container, you will see a Limits section that shows the memory limit for that container, and a Usage section that shows the current memory usage for that container.

Containers:
  my-container:
    ...
    Limits:
      memory: 1Gi
    Usage:
      memory: 500Mi
Enter fullscreen mode Exit fullscreen mode

In this example, the memory limit for the my-container container is 1GB, and the current memory usage is 500MB.

Top comments (0)