Checking kubernetes pod CPU and memory

CHECK WITHOUT METRICS SERVER or ANY THIRD PARTY TOOL


If you want to check pods cpu/memory usage without installing any third party tool then you can get memory and cpu usage of pod from cgroup.

  1. Go to pod’s exec mode kubectl exec -it pod_name -n namespace -- /bin/bash
  2. Run cat /sys/fs/cgroup/cpu/cpuacct.usage for cpu usage
  3. Run cat /sys/fs/cgroup/memory/memory.usage_in_bytes for memory usage

Make Sure you have added the resources section (requests and limits) to deployment so that it can calculate the usage based on cgroup and container will respect the limits set on pod level

NOTE: This usage is in bytes. This can vary upon pod usage and these values changes frequently.

Leave a Comment