HomeCloudKubernetes

Kubernetes · What it costs

Your cloud bill is double what it needs to be

Kubernetes cost optimization means right-sizing pods, packing nodes tightly and adding capacity only when load needs it — so your bill matches real demand.

Don't want to read the whole article?

No problem. We put everything in a 1-minute video, so you get the full idea fast.

By submitting, you agree that Sivaro may contact you about this topic.

Your cloud bill is double what it needs to be
Your cloud bill is double what it needs to be Your cloud bill is double what it needs to be

Monday morning: the finance report lands and your Kubernetes bill is up again, while the dashboards still show most containers sitting near idle. That gap is the problem this guide answers. Kubernetes cost optimization is the practice of paying only for capacity your workloads actually request, not for the ceiling someone set in a hurry. Most clusters pay for servers that sit half empty. Right-size the pods, pack them tightly and add servers only when the load needs them. The rest of this page shows how, why autoscaling alone doesn't fix it, and where the approach breaks down.

This page is one part of the Kubernetes topic map, which answers a bigger question: do you need Kubernetes, and how do you run it without waste? This part covers what it costs.

In short

  • The first mistake is trusting autoscalers to fix an over-provisioned cluster: the scheduler places pods by their requests, not by what they use, so the scheduler refuses to place a pod on a full node even when real usage is low [1].
  • Requests are the number that sets your bill, because the kubelet keeps each pod's request reserved on the node and the scheduler only places pods where the sum of requests fits [1][2].
  • Setting memory requests and limits to the same value matches how the kernel reacts: memory limits are enforced by the kernel with out-of-memory kills, which happen only when memory pressure appears [1].
  • Node autoscaling provisions nodes when pods can't be scheduled and consolidates underused nodes afterwards, and it considers pod resource requests rather than real resource usage [3].
  • Spot or preemptible capacity is the largest single discount available and fits batch or fault-tolerant work, not stateful or serving workloads [6][9].
  • Use cost-efficient infrastructure such as Spot VMs for dev/test environments and workloads that can handle interruptions [8][9].
  • The result for the business: you pay for the capacity your workloads need, plus a deliberate buffer you chose, instead of a buffer nobody measured.

At a glance

Fact Detail
What sets the bill The sum of pod requests reserved on each node, not measured usage [1][2]
How the scheduler decides It places a pod only if the sum of requests fits the node's capacity [1]
How CPU limits act CPU limits are a hard ceiling enforced by throttling [1]
How memory limits act Memory limits are enforced reactively by the kernel with OOM kills [1]
What moves saved money into reality Node autoscalers consolidate underutilized nodes [3]
Spot discount, GKE Spot prices give 60–91% off the regular price for CPU, memory and GPU [11]
Spot discount, EKS Spot instances offer up to 90% off on-demand prices, with a two-minute interruption notice [9]

Why your bill stays high when CPU looks low

Kubernetes prices capacity by reservation, not by activity. This section explains why the dashboards and the invoice tell different stories.

When you specify a resource request for a container, the kube-scheduler uses that number to decide which node the pod goes on [1]. The scheduler ensures that, for each resource type, the sum of the resource requests of the scheduled containers is less than the capacity of the node [1]. It does not look at actual usage at all. The Kubernetes documentation says it plainly: although actual memory or CPU resource usage on nodes is very low, the scheduler still refuses to place a pod on a node if the capacity check fails [1].

So a cluster can run at low CPU and memory while every node is "full" by the only measure the scheduler uses. Your team sees idle containers. The scheduler sees a cluster with no room. The bill follows the scheduler.

Requests do more than schedule. The kubelet passes each container's requests and limits to the container runtime, and on a node that uses cgroups v2 the runtime might use the memory request as a hint to set memory.min and memory.low [1]. The request is a reservation the node keeps, not a wish.

This is why a rising bill with flat usage is normal in a cluster whose requests were set once and never revisited. The fix has three parts, in this order: correct requests, tight packing, then elastic capacity. Most teams start with the third and wonder why nothing changes.

How requests and limits translate into money

Requests and limits are the two settings that turn container sizes into a monthly number. Requests decide placement and the reservation; limits decide what a container is allowed to consume.

Requests and limits, defined

A request is the amount of a resource the scheduler reserves for a container on its node. A limit is the ceiling the kernel enforces on what the container can use. CPU limits are enforced by CPU throttling: a container may not use more CPU than its limit specifies, because the kernel restricts access to the CPU once the container approaches the limit [1]. Memory limits are enforced by the kernel with out-of-memory kills: when a container uses more than its memory limit, the kernel may terminate it, but termination happens only when the kernel detects memory pressure [1].

That asymmetry matters for what you set. CPU is compressible — a throttled container runs slower. Memory is not — an over-limit container dies. Memory limits are enforced reactively, so a container can exceed its limit briefly and still be killed later [1].

The Pod is the unit that gets scheduled

Although you set requests and limits per container, the Pod's effective request and limit is what the scheduler and quota system use. Kubernetes calculates an effective init request by adding each init container's request to the requests of sidecar containers listed before it, then takes the higher of that value and the sum of all non-init containers, plus any pod overhead [2]. The scheduler places the pod only where the node has enough for the effective request, and the node keeps that reservation for the pod even after initialization finishes [2].

This is a quiet source of waste in pods with large init containers or many sidecars. If an init container asks for a wide request to warm a cache, every replica of that pod reserves that amount for the pod's whole life, not for the few seconds the init runs. The Kubernetes documentation states the consequence: init containers can reserve resources for initialization that are not used during the life of the pod [2].

What a missing limit does

If you specify a limit but no request, Kubernetes applies the limit you set and enforces it on the container [1]. That default makes the reservation equal to the ceiling — often the most expensive outcome for a workload that rarely reaches it. A container with no limit at all is unbounded: if every container in a pod leaves memory limits unspecified, the pod as a whole is not limited for that resource and can use as much as the node allows [1].

Start from measurement, not from the vendor's example manifest. Then set requests to what the workload needs to serve its traffic, and choose limits per resource: a hard CPU ceiling that does not throttle normal load, and a memory limit slightly above observed peak so the kernel never has a reason to kill.

Packing: filling the servers you already pay for

Node utilization is the share of each node's capacity that pods actually reserve. High utilization means fewer nodes carry the same pods, and that is where most of the saving lives.

Node autoscaling documentation treats utilization as the cost proxy: the main consideration when running a cluster is keeping all schedulable pods running while keeping the cost as low as possible, and from this perspective overall node utilization can be used as a proxy for how cost-effective the cluster is [3]. The same page adds a warning worth repeating: correctly setting the resource requests of your pods is as important to cost-effectiveness as optimizing node utilization [3].

Why half-empty nodes survive

Consolidation — the removal of underused nodes — only considers pod resource requests and not real resource usage when making decisions [3]. A node whose pods request nearly all its capacity will never be consolidated, even if those pods idle all day. A node with tiny requests but heavy usage looks empty and may be removed. Both behaviors follow directly from the request-based model in the previous section, and both are fixed by the same thing: requests that match reality.

Consolidation has a safety property worth knowing. Removing non-empty nodes is disruptive, because the pods on them are terminated and recreated, but all such recreated pods should be able to schedule on existing nodes or on replacement nodes provisioned as part of consolidation [3]. For the autoscaler to remove a node, the pods on it must be movable, which is why tight PodDisruptionBudgets matter — a restrictive budget blocks eviction and blocks the saving.

Get more pods per node

Three habits raise packing without touching the autoscaler. First, split sidecars and app containers into their own requests, because pods with no request on a container make CPU utilization undefined for the pod, and the Horizontal Pod Autoscaler will not act on that metric [4]. Keep startup overhead small by minimizing the time a new node sits half used. Third, do not pay for capacity by accident through memory-backed emptyDir volumes, which count against the pod's memory limit and cannot be reclaimed when the node is under pressure [1].

If your cluster has spread nodes that are each comfortably loaded but collectively oversized, the descheduler is the missing tool: it looks at pod placement after scheduling and moves pods so nodes can drain, and AWS recommends pairing it with Cluster Autoscaler to avoid wasting capacity [9]. The trade-off is churn. Run it on a schedule, not continuously.

Elastic capacity: servers that appear only when you need them

Node autoscaling adds nodes when pods cannot be scheduled and removes or consolidates nodes when they are underused. Kubernetes groups these two behaviors under autoscalers that also need explicit integration with each cloud provider's API [3].

What an autoscaler can and cannot see

Provisioning is triggered by pending pods. Autoscalers make sure provisioned nodes have enough resources to satisfy pod requests, but they do not directly take real usage into account, so scaling nodes on actual workload usage requires combining workload autoscaling with node autoscaling [3]. That gives the correct chain:

  1. Workload autoscaling changes how many pods run or how big each pod is.
  2. Pod requests change with it.
  3. Node autoscaling reacts to the new requests and provisions or removes nodes.

Break any link and the chain leaks money. An autoscaler with no workload autoscaler in front of it will never see a reason to add or remove nodes, because nothing changes the requests it reads.

The two families of autoscaler

Classic Cluster Autoscaler works on pre-defined node groups and respects each group's minimum and maximum size, adjusting only the desired count [9]. Its priority expander lets you tell it which groups to fill first, so reserved capacity is used before on-demand, and cheaper capacity before expensive capacity [9]. Karpenter takes a different approach: it provisions nodes directly from pending pods without pre-built groups, picks instance types per workload, and continuously bin-packs running pods to lower the node count [9].

The comparison is real but narrower than the marketing suggests: both change node count as pods come and go, and both need honest requests. Karpenter differs in that it can pick a more cost-efficient instance for the workload and consolidate more aggressively, at the cost of slower starts during large scaling events [9]. The Karpenter vs node pool autoscaling cost comparison covers the numbers.

Managed platforms have moved in the same direction. GKE's node auto-provisioning creates and deletes node pools on the user's behalf so the pool shape fits the scheduled workload [6]. AKS Automatic turns node auto-provisioning on by default and picks the most cost-efficient VM SKU for each workload from its requests [8].

Workload autoscaling: fewer or smaller pods, chosen on purpose

Workload autoscalers change pod count or pod size. This section compares the four you will meet and what each one actually does to the bill.

HPA, VPA, KEDA and Cluster Autoscaler side by side

Tool What it changes What it reads Where it helps the bill
HPA Number of pod replicas Metrics such as CPU utilization against requests [4] Removes pods when load drops, if requests are right
VPA Pod CPU and memory requests and limits Historical usage [6] Shrinks oversized requests so nodes consolidate
KEDA Number of pod replicas, including to zero Events such as queue length [5] Pays nothing for idle event-driven workloads
Cluster Autoscaler or Karpenter Number of nodes Pending pods and their requests [3][9] Turns reduced requests into fewer servers

The Horizontal Pod Autoscaler runs as a control loop that checks metrics on a fixed interval — --horizontal-pod-autoscaler-sync-period, default 15 seconds — and computes a desired replica count from the ratio of current metric value to target value [4]. For CPU utilization, the ratio is measured as a percentage of the container's request, so pods without a CPU request leave utilization undefined and the autoscaler takes no action for that metric [4].

The Vertical Pod Autoscaler sizes pods instead of counting them. It observes pods over time and finds the right CPU and memory, and it can run in a recommendation-only mode that publishes suggestions without applying them [6][7]. That mode is the cheapest way to learn what your requests should be: leave it running for a day, ideally a week or more, then read the recommendations and set requests statically [6].

KEDA scales on events rather than resources — messages in a queue, for example — and can scale down to zero replicas, which suits sporadic workloads and dev environments [5][8].

The pairing that breaks

The official recommendation is not to mix VPA and HPA on the same CPU or memory metric, because both would respond to the same signal and fight [6]. AKS documents the same conflict and recommends using VPA on CPU or memory with HPA on custom metrics [8]. If you want both, give each a different signal.

Autoscaling to zero

For idle-prone workloads, scaling to zero is now a first-class option. The HPA can set minReplicas: 0 for object or external metrics, scaling a workload down to no replicas when idle and back up when the metric returns; this is rejected for CPU or memory metrics, because those can only be measured on running pods [4]. KEDA and cluster-turndown controllers do the same on a schedule for test and off-hours clusters [9].

What actually drives the cost

What actually drives the cost

Four levers move a Kubernetes bill, in rough order of size.

Compute instances. In most EKS clusters, the bulk of cost comes from the EC2 instances used to run containerized workloads [9]. That is true on every cloud: the node bill, not the control plane fee, dominates.

Requests that exceed usage. If a container's requests are too high, there is unused capacity, which is a large factor in total cluster costs [9]. This is the lever your team controls most directly and it feeds every other lever.

Where the compute sits. Pricing varies per region, and picking a cheaper region is pointless if latency or data-transfer costs rise to match [6]. Long-running, predictable workloads can take committed-use discounts: GKE offers committed use discounts on the Compute Engine instances in a cluster [11], and AWS savings plans cut EC2 costs by up to 66% without committing to instance families or regions [9].

Fault tolerance as a discount. Spot capacity is the biggest single price cut available, and it is paid for in interruptions. Spot VMs on GKE are best suited to batch or fault-tolerant jobs, and stateful and serving workloads should not use them unless the system is built to handle the constraints [6]. The same source warns that PodDisruptionBudgets might not be respected because spot nodes can shut down inadvertently, and that there is no guarantee pods shut down gracefully once node preemption ignores the grace period [6].

When this is the wrong choice

Right-sizing and autoscaling fail in specific situations. In each case below, the other choice wins.

  • Predictable, steady load with no elasticity. Autoscaling gains nothing when usage does not vary. Commit instead: purchase savings plans or committed-use discounts for your known baseline and keep spot or on-demand for the rest [9][11].
  • Restrictive PodDisruptionBudgets can prevent Cluster Autoscaler and Karpenter from scaling down nodes, since both respect PodDisruptionBudgets [9][6]. Keep stateful workloads on stable capacity and reserve spot for fault-tolerant jobs.
  • Long startups and shutdowns. If an application takes minutes to start or must drain carefully, spot interruption handling and aggressive consolidation will hurt it; the AWS guide notes spot may not be the best option for such apps [9].
  • A restrictive PodDisruptionBudget with few replicas. Both Cluster Autoscaler and Karpenter respect PodDisruptionBudgets, so a budget with no headroom blocks scale-down entirely [9]. Loosen the budget before expecting the autoscaler to remove nodes.
  • A workload that cannot shrink. Some apps are single-threaded or limited by a fixed number of workers, so neither more replicas nor bigger pods help [6]. Fix the architecture, or accept the floor and commit to it.

Common mistakes

Setting requests once. Requests set at launch go stale as the app changes; continually adjusting them is more important than getting them right the first time [9]. Review them on a schedule.

Chasing nodes before pods. Installing Karpenter or Cluster Autoscaler on a cluster with inflated requests changes nothing, because consolidation only reads requests [3]. Right-size first.

No request on one container. If some containers in a pod lack a CPU request, CPU utilization for the pod is undefined and HPA takes no action for that metric [4]. Every container gets a request.

Mixing VPA and HPA on one metric. They will fight over the same signal [6][8]. Use separate metrics, or VPA in recommendation mode.

Leaving development clusters running. Small dev and test clusters accrue unnecessary cost when left unattended; cluster start/stop shuts down all node pools so you pay nothing for compute while the cluster is off [8]. Scheduled turndown does the same on AWS [9].

Assuming a cost tool is a fix. OpenCost or Kubecost shows you where the money goes; it does not change a request. Treat it as the measurement step, not the outcome.

How to check in your own system

Five signs tell you whether this page's answer fits your cluster.

  1. Usage-to-request ratio. Compare each container's actual CPU and memory against its request over a full week, including the nightly peak. Requests that are too high leave unused capacity, which is a large factor in total cluster costs [1][9].
  2. Node allocation, not node usage. Run kubectl describe nodes and read the "Allocated resources" block: the CPU and memory request percentages are the scheduler's view of fullness, and low percentages across nodes mean you are paying for empty reservation [1].
  3. Pending pods with idle nodes. Pods stuck in FailedScheduling with insufficient cpu while usage is low mean the requests are wrong, not that the cluster is too small [1].
  4. In order to autoscale Nodes based on actual workload resource usage, you can combine horizontal workload autoscaling with Node autoscaling [3][9].
  5. An HPA that cannot compute a defined utilization metric takes no action for that metric [4].

The cheapest check this week, in three steps:

  1. Pick the ten largest workloads by CPU request, not by usage.
  2. For each, compare its request with the 95th-percentile usage from your metrics store over seven days.
  3. Where request exceeds usage by a wide margin, lower the request in a test namespace, watch the pod for a day, then roll it out. Ask the node autoscaler to consolidate afterwards — that is where the saving appears.

Key terms

Request: The amount of CPU or memory the scheduler reserves for a container on a node, used to decide placement and kept reserved for the pod's life [1].
Limit: The ceiling the kernel enforces on a container's CPU or memory, through throttling for CPU and out-of-memory kills for memory [1].
Effective Pod request: The higher of the pod's initialization-phase request and its steady-state sum, plus pod overhead, which is what the scheduler actually fits [2].
Node utilization: The share of a node's capacity that pod requests consume, used as the cost-effectiveness proxy for a cluster [3].
Consolidation: The removal, possibly with replacement, of underused nodes so pods pack onto fewer machines, based on requests only [3].
Provisioning: The addition of nodes when pods cannot be scheduled, sometimes called scale-up in Cluster Autoscaler [3].
Vertical Pod Autoscaler: An add-on that observes pods and recommends or applies CPU and memory requests, available in recommendation-only mode [5][7].
Horizontal Pod Autoscaler: A built-in controller that changes replica count from metrics measured against requests [4].
Spot capacity: Spare cloud compute sold at a steep discount that can be reclaimed on short notice, suited to fault-tolerant work [6][9].

Common questions

Why is my Kubernetes bill high when CPU usage looks low?

Because the scheduler reserves capacity by requests, not by usage. It refuses to place a pod on a node whose sum of requests is full, even when actual usage on that node is very low [1]. High requests therefore produce a full-looking cluster and a full-looking bill while the dashboards show idle containers.

What should I check first?

Check requests against real usage for your largest workloads, before touching autoscalers. Node consolidation only reads requests, so an autoscaler in front of oversized requests will do nothing [3]. A recommendation-only VPA for a week gives you the numbers with no risk [6].

How do I right-size CPU and memory without causing outages?

Set memory requests equal to memory limits and move requests down in steps, watching for OOM kills and throttling. Memory limits are enforced reactively by the kernel with OOM kills under pressure, so an over-tight limit shows up as restarts [1]. For CPU, lower the request toward the observed load and keep a ceiling that does not throttle your normal peak. Test in a non-production namespace first.

Should I use HPA, VPA, KEDA, Cluster Autoscaler, or Karpenter?

Use HPA for replica count on steady services, VPA for sizing pods, KEDA for event-driven workloads that should scale to zero, and Cluster Autoscaler or Karpenter for nodes [3][4][5][8]. They solve different problems and belong in the same cluster at different layers. Never run VPA and HPA on the same metric [6].

Does autoscaling actually lower the bill?

Autoscaling lowers the bill only when the nodes it frees are really removed or consolidated, and that depends on correct requests. Node autoscalers provision from requests and consolidate by requests, not by real usage [3]. Without right-sized pods, autoscaling mostly moves cost around.

Should I turn development and test environments off at night?

Yes. Cluster start/stop shuts down all system and user node pools so you do not pay for compute, and the cluster's state is kept for the next start [8]. Scheduled controllers can scale test clusters to zero on a cron, which removes whole clusters of spend instead of trimming them [9].

Are Spot or preemptible machines worth the risk?

Worth it for batch and fault-tolerant jobs, where the savings are large and interruptions are survivable [6][9]. Not worth it for stateful or serving workloads unless the system is built for interruption, because reclaims come with short notice and PodDisruptionBudgets might not hold [6].

Will OpenCost or Kubecost lower the bill by itself?

No. A cost tool allocates and reports spend; it does not change a request, a limit or a node count. Use it to find the workloads whose requests exceed usage, then change the settings; the tools meet you halfway.

Why do my savings not appear after I lower requests?

Because freeing reservation on a node does not remove the node. The node autoscaler must consolidate or remove it, and that can be blocked by a restrictive PodDisruptionBudget, pods without a controller or pods with local storage [3][9]. Check autoscaler events to see what blocked the removal.

Beyond pods: the rest of the cluster bill

Three costs sit outside the request model and still show up on the invoice.

Observability. Metrics and logs are billed by volume. Container Insights users on AKS are advised to migrate to managed Prometheus for a significant cost reduction [8], and both GKE and AWS bill logging by the amount you keep [6][9]. Sample what you don't query.

Control plane tiers and support windows. Managed control planes charge per cluster, and staying on an old Kubernetes version costs more: EKS charges extended support for versions past standard support [10], and GKE charges an extended period cluster management fee after a minor version leaves standard support [11]. Upgrading on schedule is a cost decision.

Networking and storage. Cross-zone traffic in regional clusters is billed as egress [6], and volumes persist whether or not a pod mounts them. Neither is large next to compute, but both are ignored until they aren't.

These costs need the same discipline as pods: measure first, then change one thing at a time. For a wider set of practitioner habits, see Kubernetes cost optimization best practices.

References

References
  1. Resource Management for Pods and Containers | Kubernetes
  2. Effective Pod requests and limits | Kubernetes
  3. Node Autoscaling | Kubernetes
  4. Horizontal Pod Autoscaling | Kubernetes
  5. Autoscaling Workloads | Kubernetes
  6. Best practices for running cost-optimized Kubernetes applications on GKE
  7. Scale container resource requests and limits | Google Kubernetes Engine (GKE)
  8. Best Practices for Cost Optimization in Azure Kubernetes Service (AKS)
  9. Compute and Autoscaling - Amazon EKS
  10. Amazon EKS Pricing
  11. Google Kubernetes Engine pricing | Google Cloud

Want to talk this through?