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

<p>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. </p>

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

<p>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 <a href="https://prometheus.io/" rel="nofollow noreferrer">Prometheus</a>. You can also visualize its content using another popular tool: <a href="https://grafana.com/" rel="nofollow noreferrer">Grafana</a>.  There are other open-source alternatives too. For example, <a href="https://www.influxdata.com/" rel="nofollow noreferrer">InfluxDB</a>.</p>

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

<ul>
<li><a href="https://www.datadoghq.com/" rel="nofollow noreferrer">Datadog</a></li>
<li><a href="https://sysdig.com/" rel="nofollow noreferrer">Sysdig</a></li>
<li><a href="https://www.signalfx.com/" rel="nofollow noreferrer">SignalFX</a></li>
<li><a href="https://newrelic.com/" rel="nofollow noreferrer">New Relic</a></li>
<li><a href="https://www.dynatrace.com/" rel="nofollow noreferrer">Dynatrace</a> </li>
<li>Etc...</li>
</ul>
