On a Kubernetes cluster you pay for nodes, and nodes are sized by what pods request, not by what they use. The scheduler places a pod wherever its requested CPU and memory fit. If a service asks for four cores and uses half of one, the cluster still keeps four cores free for it, and the autoscaler buys nodes to match.
That makes the gap between requested and used the most useful first number in a Kubernetes cost review. It is cheap to measure, it points at specific workloads, and closing it is usually a configuration change, not a re-architecture.
Why the gap appears
Requests are set by people, usually once, usually under pressure:
- Copied defaults. A Helm chart or template ships with generous requests, and nobody revisits them.
- Sized for the worst day. Requests are set for a launch or an incident and never brought back down.
- Memory fear. Memory limits that are too low cause OOM kills, so teams pad memory requests "to be safe".
- No feedback loop. Engineers rarely see the cost of what they request, so there is no reason to trim it.
None of this is negligence. It is what happens when the cost of over-requesting is invisible to the person setting the number.
How to measure it
If you run Prometheus with kube-state-metrics and cAdvisor (many clusters do), you already have the data.
Requested CPU by namespace:
sum by (namespace) (
kube_pod_container_resource_requests{resource="cpu"}
* on (namespace, pod) group_left()
max by (namespace, pod) (kube_pod_status_phase{phase="Running"})
)
The join with kube_pod_status_phase matters: kube-state-metrics keeps reporting requests for finished pods, such as completed Jobs, until they are deleted.
Used CPU by namespace (cores, averaged over five minutes):
sum by (namespace) (
rate(container_cpu_usage_seconds_total{container!="", container!="POD"}[5m])
)
Do the same for memory with the same query with resource="memory", and container_memory_working_set_bytes{container!="", container!="POD"}.
Two details matter more than the queries themselves:
- Use a long window. A single afternoon tells you nothing. Look at at least one to two weeks, so weekly peaks and batch jobs are included.
- Compare requests with a high percentile, not the average. A service that averages 0.3 cores but spikes to 1.8 every hour needs more than 0.3. A p95 or p99 of usage over the window is a fairer target than the mean:
quantile_over_time(0.95,
sum by (namespace, pod) (
rate(container_cpu_usage_seconds_total{container!="", container!="POD"}[5m])
)[14d:5m]
)
Reading the result
Sort workloads by the absolute gap, not the percentage. A small service that requests ten times what it uses matters less than a large one that requests twice what it uses.
Then separate the gap into three kinds:
- Safe to trim. Steady services with a large, consistent gap. Lower the request toward the high percentile plus a margin.
- Spiky. Services whose peaks are real. Trimming requests here needs care; horizontal autoscaling is often the better tool.
- Memory-bound. Memory can't be throttled like CPU: a container that exceeds its limit is killed. Trim memory more conservatively than CPU and watch for OOM kills after each change.
What closing the gap actually saves
Lower requests only save money if the cluster can then run on fewer or smaller nodes. That depends on the autoscaler being able to consolidate: pod disruption budgets, anti-affinity rules and node-pool shapes can all stop it from removing nodes even after requests drop.
So treat right-sizing as two steps. First, bring requests in line with real usage. Second, check that node count actually follows. If it doesn't, the bottleneck is bin-packing, not requests, and that is a separate fix.
A sensible order of work
- Measure requested vs used for every workload over two weeks.
- Rank by absolute gap and pick the steady, high-gap services first.
- Change requests through your normal review process, a few services at a time.
- Watch latency, throttling and OOM kills for a week after each change.
- Confirm the node count went down. If it didn't, look at consolidation next.
The point of starting here is that it turns "Kubernetes is expensive" into a ranked list of specific workloads, with a number next to each one.
Related solutions
A 30-minute sanity check: an outside read on the cost mechanisms most worth checking, and whether a full assessment is worth it.