dockerkubernetesresource-utilization

How do I find how much actual CPU a kubernetes pod/container is using?


I am trying to optimize the CPU resources allocated to a pod based on previous runs of that pod.

The only problem is that I have only been able to find how much CPU is allocated to a given pod, not how much CPU a pod is actually using.


Solution

  • That information is not stored anywhere in Kubernetes. You typically can get the 'current' CPU utilization from a metrics endpoint.

    You will have to use another system/database to store that information through time. The most common one to use is the open-source time series DB Prometheus. You can also visualize its content using another popular tool: Grafana. There are other open-source alternatives too. For example, InfluxDB.

    Also, there are a ton of commercial solutions that support Kubernetes metrics. For example: