Monitoring memory usage allows you to identify pods and nodes that are consuming excessive resources. By doing so, you can take corrective actions, such as optimizing the resource allocation, scaling your applications, or troubleshooting potential memory leaks. This proactive approach helps ensure that your Kubernetes cluster runs efficiently and avoids unexpected downtimes.
This guide provides instructions on how to monitor memory usage in Kubernetes pods and nodes using the kubectl top
command. Make sure that the metrics server is enabled in your Kubernetes cluster.
Verifying Pod Memory Usage
Command to Check Pod Memory Usage
Example Output:
- CPU (cores): The amount of CPU being used by the pod.
- MEMORY (bytes): The amount of memory being used by the pod.
Verifying Node Memory Usage
Command to Check Node Memory Usage
Example Output:
- CPU (cores): The amount of CPU being used by the node.
- CPU%: The percentage of CPU capacity being utilized by the node.
- MEMORY (bytes): The amount of memory being used by the node.
- MEMORY%: The percentage of memory capacity being utilized by the node.