Question: 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.

Answer: 
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](https://prometheus.io/). You can also visualize its content using another popular tool: [Grafana](https://grafana.com/). There are other open-source alternatives too. For example, [InfluxDB](https://www.influxdata.com/).

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

* [Datadog](https://www.datadoghq.com/)
* [Sysdig](https://sysdig.com/)
* [SignalFX](https://www.signalfx.com/)
* [New Relic](https://newrelic.com/)
* [Dynatrace](https://www.dynatrace.com/)
* Etc...
I may be reading too much into how the question is worded: (quote) "how much CPU a pod is actually using"...even though the question also mentions (quote) "to optimize...based on previous runs". So:

For usage history - see Rico's answer.

For current usage, see [`kubectl top`](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-pod-em-). Use `watch` to see usage stats every 2 seconds without having to run the command over and over. For example:

```
watch kubectl top pod <pod-name> --namespace=<namespace-name>

```

This can be helpful, too: <https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/#resource-metrics-pipeline>