104k views
1 vote
How to check pod cpu and memory usage

User AliS
by
6.6k points

1 Answer

2 votes

Final answer:

To check CPU and memory usage of Kubernetes pods, use the 'kubectl top' command, ensuring the Metrics Server is installed. For detailed monitoring, use tools like Prometheus and Grafana.

Step-by-step explanation:

To check the CPU and memory usage of pods in a Kubernetes cluster, one commonly used command-line tool is kubectl. You can use the kubectl top command to display the current CPU and memory usage for a specific pod or for all pods within a namespace. For instance, to see the usage of all pods in a particular namespace, you would run kubectl top pods --namespace=<your_namespace>. If you want to check the usage of a specific pod, the command is kubectl top pod <pod_name> --namespace=<your_namespace>. It’s important to ensure that the Metrics Server is installed on your cluster as it provides the metric data that kubectl top uses.

In circumstances where more detailed metrics are needed, monitoring tools like Prometheus combined with Grafana can be used for in-depth analysis and visualization. Remember that maintaining resource usage within the optimal range is crucial for the efficient operation of a Kubernetes cluster.

User JPrescottSanders
by
7.5k points