Skip to main content
Cloud DevOps Solutions
Get a quote Talk to an engineer
Cloud Cost 2026-11-12 16 min read

Kubernetes Cost Optimisation: Requests, Limits, Autoscaling, and Right-Sizing

Saddique Khan

DevOps / SRE Engineer & CEO, Cloud DevOps Solutions

Kubernetes makes it easy to deploy applications. It also makes it easy to waste money. A cluster where every team requests 4 CPU and 8 GiB of memory “just in case” runs at 15% utilisation while the bill grows as if it were fully loaded. Multiply that across staging, dev, and production clusters and you have a cost problem that dashboards alone will not solve.

The root cause is almost always the same: resource requests that do not match actual usage. Everything else, oversized nodes, idle namespaces, On-Demand pricing, follows from that first misconfiguration.

This guide covers the techniques that consistently deliver the largest savings on Kubernetes, applicable to EKS, AKS, and GKE.

Why Kubernetes costs are hard to control

Cloud provider billing does not understand Kubernetes. Your AWS bill shows EC2 instance charges, not “the checkout service used 2.3 CPU for 720 hours.” Mapping costs to teams, services, and environments requires a layer of instrumentation that Kubernetes does not provide out of the box.

Three factors compound the problem:

  1. Over-requesting: developers set resource requests high to avoid OOMKills and throttling. The scheduler reserves that capacity on a node even if the pod never uses it.
  2. Under-utilisation: the gap between requested and actual usage is wasted node capacity that you pay for.
  3. No chargeback: without cost visibility per namespace or team, nobody owns the waste. The platform team sees the total bill; the application teams see unlimited free compute.

Fixing Kubernetes costs means addressing all three: right-size requests, automate scaling, and make costs visible to the teams that generate them.

1. Right-size resource requests and limits

Resource requests are the single most important cost lever in Kubernetes. The scheduler uses requests to decide which node a pod runs on. If a pod requests 4 CPU but uses 0.5, the scheduler reserves 4 CPU on the node, and those 3.5 unused cores cannot be used by other pods (unless they have no requests, which creates its own problems).

Measuring actual usage

Before changing requests, measure what pods actually consume:

Metrics Server provides real-time CPU and memory usage:

kubectl top pods -n production --sort-by=cpu

Prometheus + Grafana provides historical data. The key queries:

# Average CPU usage over 7 days
avg_over_time(
  rate(container_cpu_usage_seconds_total{namespace="production"}[5m])[7d:1h]
)

# P95 memory usage over 7 days
quantile_over_time(0.95,
  container_memory_working_set_bytes{namespace="production"}[7d:1h]
)

Kubecost and OpenCost provide pre-built dashboards showing the gap between requested and actual resources per pod, deployment, and namespace. See our cloud cost optimisation tools comparison for setup details.

Setting right-sized requests

The formula:

  • CPU request: P95 CPU usage over 7 days + 10-20% buffer
  • Memory request: P95 memory usage over 7 days + 15-25% buffer (memory is less elastic than CPU; OOMKill is more disruptive than CPU throttling)
  • CPU limit: consider not setting one (see below)
  • Memory limit: equal to or slightly above the memory request

The CPU limits debate

CPU limits cause throttling even when the node has spare capacity. A pod that bursts to 2 CPU for 100ms during a request gets throttled to its limit, adding latency, even if the node is running at 30% utilisation.

Many teams, including those running large Kubernetes platforms at scale, have removed CPU limits entirely. The pod still gets its requested CPU guaranteed, but can burst above it when the node has capacity. This improves application performance without increasing cost.

Keep memory limits. Unlike CPU (which throttles), exceeding a memory limit triggers an OOMKill. Without memory limits, a memory leak in one pod can consume the entire node and affect other workloads.

Example: right-sizing a deployment

Before:

resources:
  requests:
    cpu: "2"
    memory: "4Gi"
  limits:
    cpu: "2"
    memory: "4Gi"

Actual usage (from Prometheus): P95 CPU 0.3, P95 memory 800 MiB.

After:

resources:
  requests:
    cpu: "400m"
    memory: "1Gi"
  limits:
    memory: "1536Mi"

This single change frees 1.6 CPU and 2.5 GiB per replica. With 10 replicas, that is 16 CPU and 25 GiB of node capacity recovered, enough to remove 2-3 nodes from the cluster.

2. Use the Vertical Pod Autoscaler (VPA)

Manually right-sizing hundreds of deployments is not sustainable. The Vertical Pod Autoscaler automates it.

VPA analyses historical resource usage and recommends (or automatically applies) updated requests and limits. It operates in three modes:

  • Off: generates recommendations only (check with kubectl describe vpa)
  • Initial: applies recommendations only when pods are created (not to running pods)
  • Auto: evicts and recreates pods with updated requests

VPA configuration

apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: checkout-service-vpa
  namespace: production
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: checkout-service
  updatePolicy:
    updateMode: "Auto"
  resourcePolicy:
    containerPolicies:
      - containerName: app
        minAllowed:
          cpu: "100m"
          memory: "128Mi"
        maxAllowed:
          cpu: "4"
          memory: "8Gi"
        controlledResources: ["cpu", "memory"]

VPA best practices

  • Start in Off mode for production workloads. Review recommendations for two weeks before enabling Auto.
  • Set minAllowed and maxAllowed to prevent VPA from scaling to absurd values.
  • Do not use VPA with HPA on the same resource dimension. If HPA scales on CPU, VPA should only control memory (or vice versa). The Multidimensional Pod Autoscaler (MPA) in some distributions handles both.
  • VPA restarts pods when it changes requests in Auto mode. This is safe for stateless services but disruptive for stateful workloads or singletons.

3. Configure Horizontal Pod Autoscaling (HPA) effectively

HPA scales the number of pod replicas based on metrics. Misconfigured HPA either wastes money (too many replicas) or causes outages (too few).

Common HPA mistakes

Setting minReplicas too high: a service with minReplicas: 10 that only needs 2 replicas at night wastes 80% of its off-peak compute.

Scaling on CPU alone: CPU-based HPA responds slowly to traffic spikes. Add custom metrics (requests per second, queue depth) for faster scaling.

Missing scale-down stabilisation: without scaleDown.stabilizationWindowSeconds, HPA oscillates between scaling up and down as load fluctuates around the threshold.

Optimised HPA example

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api-service
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api-service
  minReplicas: 2
  maxReplicas: 20
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70
    - type: Pods
      pods:
        metric:
          name: http_requests_per_second
        target:
          type: AverageValue
          averageValue: "100"
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 300
      policies:
        - type: Percent
          value: 10
          periodSeconds: 60
    scaleUp:
      policies:
        - type: Percent
          value: 50
          periodSeconds: 60

This configuration scales up aggressively (50% more pods per minute) but scales down conservatively (10% reduction per minute with a 5-minute stabilisation window), preventing thrashing.

4. Optimise node provisioning with Karpenter

The Cluster Autoscaler is the traditional approach to node scaling in Kubernetes. Karpenter, originally built for EKS and now available for AKS (preview), replaces it with faster, more cost-efficient provisioning.

How Karpenter saves money

  • Right-sized nodes: Karpenter selects the cheapest instance type that fits pending pods, rather than scaling a fixed node group. If a pod needs 500m CPU and 1 GiB, Karpenter might provision a t3.small instead of the m5.xlarge in your node group.
  • Bin-packing: Karpenter consolidates underutilised nodes by moving pods and removing empty nodes.
  • Spot integration: Karpenter requests Spot capacity across many instance types, improving availability and reducing cost.
  • Faster scaling: provisions nodes in seconds (directly via the EC2 Fleet API) versus minutes for Cluster Autoscaler.

Karpenter NodePool configuration

apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: default
spec:
  template:
    spec:
      requirements:
        - key: karpenter.sh/capacity-type
          operator: In
          values: ["spot", "on-demand"]
        - key: kubernetes.io/arch
          operator: In
          values: ["amd64", "arm64"]
        - key: karpenter.k8s.aws/instance-category
          operator: In
          values: ["c", "m", "r"]
        - key: karpenter.k8s.aws/instance-generation
          operator: Gt
          values: ["5"]
      nodeClassRef:
        group: karpenter.k8s.aws
        kind: EC2NodeClass
        name: default
  limits:
    cpu: "100"
    memory: "400Gi"
  disruption:
    consolidationPolicy: WhenEmptyOrUnderutilized
    consolidateAfter: 30s

This configuration allows Karpenter to use Spot or On-Demand, amd64 or arm64 (Graviton), from the c/m/r families, generation 6+. It consolidates underutilised nodes after 30 seconds.

Karpenter vs Cluster Autoscaler

DimensionKarpenterCluster Autoscaler
Instance selectionAny matching typeFixed per node group
Scaling speedSecondsMinutes
Spot handlingMulti-instance-type fleetPer node group
ConsolidationBuilt-inNot supported
Cloud supportEKS (GA), AKS (preview)EKS, AKS, GKE
Graviton awarenessYes (mixed arch)Requires separate node group

For EKS clusters, Karpenter is the recommended choice. For GKE, use the GKE Node Auto-Provisioning (NAP) feature, which provides similar capabilities natively.

5. Use Spot and preemptible nodes

Spot instances (AWS), Spot VMs (Azure), and Preemptible VMs (GCP) offer 60-90% discounts over On-Demand pricing. The trade-off: the cloud provider can reclaim the capacity with short notice (2 minutes on AWS, 30 seconds on Azure, 30 seconds on GCP).

What to run on Spot

  • Stateless services with multiple replicas (the remaining replicas handle traffic during rescheduling)
  • Batch jobs with checkpointing
  • CI/CD build pods
  • Dev and staging workloads
  • Data processing pipelines

What to keep on On-Demand

  • Cluster system components (CoreDNS, kube-proxy, monitoring agents)
  • Stateful workloads without fast failover (databases, message brokers)
  • Single-replica services where any downtime is unacceptable

Implementation pattern

Use node taints and pod tolerations to separate Spot and On-Demand workloads:

# Pod tolerates Spot nodes
tolerations:
  - key: "kubernetes.azure.com/scalesetpriority"
    operator: "Equal"
    value: "spot"
    effect: "NoSchedule"
# Prefer Spot but allow On-Demand as fallback
affinity:
  nodeAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 100
        preference:
          matchExpressions:
            - key: "karpenter.sh/capacity-type"
              operator: In
              values: ["spot"]

A typical production cluster running 70% Spot and 30% On-Demand saves 40-55% on compute. See our EKS cost optimisation guide for EKS-specific Spot strategies.

6. Set namespace quotas and LimitRanges

Without guardrails, any team can request unlimited resources. Namespace quotas enforce budgets at the Kubernetes level.

ResourceQuota

apiVersion: v1
kind: ResourceQuota
metadata:
  name: team-checkout-quota
  namespace: team-checkout
spec:
  hard:
    requests.cpu: "20"
    requests.memory: "40Gi"
    limits.memory: "60Gi"
    pods: "50"
    persistentvolumeclaims: "10"

This caps the total resources the team-checkout namespace can request, regardless of how many deployments they create.

LimitRange

LimitRange sets defaults and constraints per pod/container, so developers who forget to specify resources get sensible defaults instead of unbounded allocation:

apiVersion: v1
kind: LimitRange
metadata:
  name: default-limits
  namespace: team-checkout
spec:
  limits:
    - type: Container
      default:
        cpu: "500m"
        memory: "512Mi"
      defaultRequest:
        cpu: "200m"
        memory: "256Mi"
      max:
        cpu: "4"
        memory: "8Gi"
      min:
        cpu: "50m"
        memory: "64Mi"

7. Consolidate clusters

Many organisations run separate clusters per team, per environment, or per application. Each cluster has fixed overhead:

  • Control plane: $73/month on EKS, free on GKE (Standard), varies on AKS
  • System pods: CoreDNS, kube-proxy, CNI, monitoring agents consume node capacity
  • Node minimum: even a small cluster needs at least 2-3 nodes for resilience

When to consolidate

  • Multiple small clusters (under 10 nodes each) with low utilisation
  • Dev and staging clusters that could share a single cluster with namespace isolation
  • Per-team clusters where the teams do not need separate control planes

How to consolidate safely

  • Use namespaces with RBAC for team isolation
  • Apply NetworkPolicies to restrict cross-namespace traffic
  • Set ResourceQuotas per namespace to prevent one team from starving others
  • Use separate node pools for workloads that need different instance types or security boundaries

Consolidating 5 small clusters (3 nodes each) into 1 cluster (8 nodes) saves the control plane costs and recovers the node capacity lost to system pods across 5 separate clusters.

8. Optimise persistent storage

Persistent volumes often outlive the pods that created them. Common waste:

Reclaim policies

By default, when a PVC is deleted, the underlying volume is retained (ReclaimPolicy: Retain). This is safe but accumulates unused volumes. For non-critical data (caches, temp storage), use Delete as the reclaim policy.

Storage class selection

Not every volume needs premium SSD. Match the storage class to the workload:

WorkloadRecommended tierExample (AWS)
Production databasesHigh-performance SSDgp3 (provisioned IOPS if needed)
Application dataGeneral SSDgp3 (baseline)
Logs and temp dataHDD or ephemeralsc1 or emptyDir
Build cachesEphemeralemptyDir with sizeLimit

Find and clean up unused PVCs

# Find PVCs not mounted by any pod
kubectl get pvc -A -o json | jq -r '
  .items[] |
  select(.status.phase == "Bound") |
  select(.metadata.annotations["volume.kubernetes.io/storage-provisioner"] != null) |
  "\(.metadata.namespace)/\(.metadata.name) - \(.spec.resources.requests.storage)"
'

Cross-reference with pods that actually mount each PVC. Unattached PVCs backed by cloud volumes cost money every hour.

9. Schedule non-production workloads

Dev and staging clusters that run 24/7 but are used only during business hours waste 70% of their compute. Options:

Scale to zero

For EKS and AKS, use Karpenter or Cluster Autoscaler with node pools that scale to zero when no pods are scheduled. Combine with a CronJob or external scheduler that scales deployments to 0 replicas at night:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: scale-down-dev
spec:
  schedule: "0 18 * * 1-5"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: scaler
              image: bitnami/kubectl:latest
              command:
                - /bin/sh
                - -c
                - |
                  kubectl scale deployment --all --replicas=0 -n dev
          restartPolicy: Never

Cluster hibernation

EKS and AKS support stopping clusters entirely. A stopped cluster incurs no node costs (EKS still charges $73/month for the control plane; AKS control plane is free).

Savings impact

A 10-node dev cluster at $3,000/month running only during business hours (50 hours/week vs 168):

  • Scale to zero at night: ~$900/month (70% saving)
  • Cluster hibernation (weekdays only, 10 hours/day): ~$900/month

10. Make costs visible with Kubecost or OpenCost

Cost optimisation without visibility is unsustainable. Engineers need to see what their workloads cost.

Kubecost

Kubecost runs inside the cluster and provides:

  • Per-pod, per-deployment, per-namespace cost allocation
  • Idle cost identification (allocated but unused resources)
  • Right-sizing recommendations
  • Multi-cluster cost aggregation
  • Savings recommendations with estimated impact

OpenCost

OpenCost is the CNCF sandbox project that Kubecost’s free tier is built on. It provides the core cost allocation engine without the commercial features (multi-cluster, recommendations, alerts).

Showback and chargeback

Once costs are visible per namespace, implement showback: share cost reports with each team monthly. This alone changes behaviour. Teams that see “$12,000/month” next to their namespace start asking questions about those 4-CPU requests.

For organisations that want formal chargeback (teams pay for their usage from their own budgets), Kubecost and cloud provider billing APIs provide the data to build allocation models.

Putting it together: a cost optimisation roadmap

Week 1: Visibility

  • Install Kubecost or OpenCost
  • Identify the top 10 most expensive namespaces
  • Measure the gap between requested and actual CPU/memory

Week 2-3: Quick wins

  • Right-size the worst offenders (biggest gap between request and usage)
  • Set LimitRanges on all namespaces so new pods get sensible defaults
  • Schedule dev/test clusters to scale down outside hours

Month 2: Structural changes

  • Deploy VPA in Off mode, review recommendations
  • Migrate to Karpenter (EKS) or enable NAP (GKE)
  • Add Spot node pools for fault-tolerant workloads
  • Implement namespace quotas

Month 3: Governance

  • Establish a monthly cost review cadence per team
  • Set up Kubecost alerts for cost anomalies
  • Add cost estimation to CI/CD (Infracost for Terraform, Kubecost cost prediction for Helm charts)

For teams that want help implementing this roadmap, our cloud cost optimisation service combines Kubernetes-specific techniques with broader cloud cost strategy. We also cover Kubernetes monitoring in our Prometheus and Grafana guide.

Key takeaways

  • Resource requests are the primary cost lever: right-size them to P95 usage plus a buffer, not to theoretical maximums
  • Remove CPU limits on most workloads to eliminate unnecessary throttling without increasing cost
  • VPA automates right-sizing; start in Off mode and graduate to Auto after validating recommendations
  • Karpenter (EKS) and Node Auto-Provisioning (GKE) select the cheapest node for each pod, replacing fixed node groups
  • Spot nodes save 60-90% on compute for stateless, multi-replica workloads
  • Namespace quotas and LimitRanges prevent waste from accumulating as teams scale
  • Cost visibility (Kubecost or OpenCost) is the foundation: teams that see their costs reduce them

Running Kubernetes and want to cut your infrastructure bill? Book a free consultation and we will analyse your cluster costs together.

#kubernetes #cost-optimization #karpenter #spot-instances #finops #eks #aks

Related service

Need hands-on help? Our certified engineers deliver this as a managed service.

Kubernetes Consulting
Found this useful? Share it with your team or link to it from your documentation.

Need help implementing this?

Our certified engineers can handle the setup, migration, or ongoing operations for you.