Reputation: 21
In CNF world, measuring the CPU usage on a POD with usual commands for example, top command doesnot actually provide the POD's actual CPU usage, instead it will be like you run it on the host system/node because the pod is using kernel of the host system.
We have to periodically monitor the CPU usage inside the POD and throttle the traffic. Is there a way to measure the CPU usage inside the POD?
top command doesnot actually provide the POD's actual CPU usage, instead it provides the host system/node usage, because the pod is using kernel of the host system.
Upvotes: 0
Views: 2125
Reputation: 1167
From the way you present the question I think you don't want the answer "install a monitoring stack consisting of Prometheus, Alertmanager and Grafana to monitor the infrastructure".
You could simply do these steps:
1.Log into the Pod
kubectl -n NAMESPACE exec -it POD_NAME —- bash (or sh)
2.Run the command
/sys/fs/cgroup/cpu/cpuacct.usage
for cpu usage
Take a look at this docs: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/sec-cpuacct
Checking kubernetes pod CPU and memory
Upvotes: 0