Kubernetes Cost Optimization: A Four-Step Framework
Four steps to bring Kubernetes costs down without hurting reliability: measure, right-size, autoscale on real signals, and buy capacity last.
By VVVHQ Team ·
Where Kubernetes money goes
Kubernetes defaults are generous, and a cluster bill has few natural owners. Nodes are shared, requests are guessed at launch, and costs that would be obvious on a single server disappear into the cluster total. The waste usually sits in four places.
Nodes larger than the workload
Instance types chosen during the first setup tend to stay. A cluster on m5.2xlarge nodes may have pods that would pack just as well onto smaller nodes, or onto fewer of the same size. Compare two numbers per node: the CPU and memory requested by pods against what the node can allocate, which shows how well the scheduler is packing, and actual usage against requests, which shows how much of each request is padding. kubectl top nodes shows a single moment; use a few weeks of Prometheus data for the decision.
Forgotten workloads
Development namespaces with deployments no one uses, staging environments running all week, and load-test leftovers that outlive the test by months.
Missing or padded requests
Without requests, the scheduler cannot pack pods well. With requests set far above real usage, it packs them well onto nodes that sit mostly idle.
Logging and monitoring
Log volume and paid observability features grow with every service and rarely have an owner. Our post on building a FinOps practice walks through one review where a single service produced more than half of the log volume.
Step 1: measure
Collect resource usage at pod, namespace and cluster level with Prometheus, and add cost allocation with OpenCost (open source) or Kubecost. Watch these ratios:
- CPU requested against CPU used.
- Memory requested against the working set.
- Node allocatable against what pods have requested.
- Cost per namespace per day.
Step 2: right-size workloads
From a few weeks of history, set requests close to real usage with sensible headroom. The Vertical Pod Autoscaler in recommendation mode, Kubecost's recommendations and a few Prometheus queries are enough to produce a list per deployment. Change non-critical services first and watch for throttling and OOM kills before moving on.
Step 3: autoscale on real signals
A Horizontal Pod Autoscaler on CPU alone often scales on the wrong signal. Scale on what the service actually does: requests per second for APIs, queue depth for workers, connection count for proxies. KEDA makes event-driven scaling, including scaling idle workers to zero, straightforward.
At node level, Karpenter or Cluster Autoscaler adds and removes nodes as pods need them. Karpenter's consolidation also moves pods onto fewer nodes when load drops, so set Pod Disruption Budgets for services that cannot lose replicas at an arbitrary moment.
Review NodePool limits with the same care as pod requests. For one client, a production Helm upgrade failed with UPGRADE FAILED: context deadline exceeded, and nothing was wrong with the release. The spot ARM NodePool's limits (cpu 20, memory 88Gi) left room only for .large instances, whose allocatable CPU (1930m) is below the pod's request (1946m). The new pods could never be scheduled, and Helm timed out waiting for them. Raising the limits to cpu 30 and 120Gi and allowing more spot instance types let the deploy go through.
Step 4: buy capacity the right way
Run fault-tolerant workloads such as stateless APIs, batch jobs and CI runners on Spot or preemptible nodes, with On-Demand as the fallback. Cover the steady baseline you measured in step 1 with Savings Plans or committed use discounts, and commit only after right-sizing, so you are not paying in advance for capacity you were about to remove.
Where to start
- Install OpenCost or Kubecost and let it collect a week of data.
- List the most over-provisioned workloads by the gap between requests and usage.
- Right-size the non-critical ones first, then the rest.
- Delete workloads without an owner.
Our cost reviews are done alongside the client's engineer, and the changes land in the client's own manifests and Terraform. When a cluster bill keeps growing and no one can say why, tell us about the cluster and we will say where we would look first.