Skip to content

Repository files navigation

EKS Cost Optimization

A sanitized, opinionated reference for cutting the compute bill on Amazon EKS without sacrificing reliability. It pulls together the four levers that move the needle most — Karpenter consolidation, Graviton migration, rightsizing, and honest OpenCost vs. Kubecost measurement — as adaptable patterns rather than a drop-in install.

Sanitized reference. Cluster names, roles, cost centers, and limits here are examples (example-cluster, cc-1001, payments). Treat this as a pattern library to adapt to your own cluster, not a copy-paste deploy.

The four levers

Lever What it saves Where
Karpenter Bin-packs pods onto fewer, right-sized nodes; Spot-first with consolidation karpenter/
Graviton ~20% price/performance vs. equivalent x86 for many workloads graviton/
Rightsizing Removes the padding between requests and real usage rightsizing/
Measurement OpenCost/Kubecost attribute net (CUR-based) spend by team/namespace cost-tools/

How the levers reinforce each other

flowchart TD
    RS[Rightsizing<br/>requests match real usage] --> PACK
    subgraph PACK[Karpenter]
      CONS[Consolidation<br/>bin-pack onto fewer nodes]
      SPOT[Spot-first + On-Demand fallback]
      GRAV[Graviton NodePool<br/>arm64, weighted-preferred]
    end
    GR[Graviton-ready workloads<br/>multi-arch images] --> GRAV
    PACK --> NODES[Fewer, cheaper, better-utilized nodes]
    NODES --> MEAS[OpenCost / Kubecost<br/>net cost via CUR]
    MEAS -->|shows remaining waste| RS
Loading
  • Rightsizing shrinks per-pod requests, so Karpenter can pack more pods per node.
  • Karpenter consolidation then removes the now-underutilized nodes.
  • Graviton makes each of those nodes cheaper for the same performance.
  • OpenCost/Kubecost measure net spend by team and feed the next rightsizing pass.

Order matters: rightsize first, then let consolidation and Graviton compound the savings. Measurement closes the loop.

Repository layout

Path Contents
karpenter/ NodePool + EC2NodeClass — Spot-first general pool, weighted Graviton pool, consolidation
graviton/ Migration playbook, multi-arch Dockerfile, arm64-ready workload example
rightsizing/ Recommendation-only VPA manifest + a kubectl top usage-vs-requests report script
cost-tools/ OpenCost and Kubecost Helm values (CUR net pricing) + a decision comparison
docs/ Deep dives on each lever + the OpenCost-vs-Kubecost decision
examples/ End-to-end sample workload wired for Graviton + rightsizing

Quickstart

Apply the Karpenter node configuration (requires Karpenter installed in the cluster):

kubectl apply -f karpenter/ec2nodeclass.yaml
kubectl apply -f karpenter/nodepool-general.yaml
kubectl apply -f karpenter/nodepool-graviton.yaml

Get right-sizing recommendations without touching workloads (VPA in Off mode):

kubectl apply -f rightsizing/vpa/payments-api-vpa.yaml
kubectl describe vpa payments-api -n payments   # read the recommendation

Spot over-/under-provisioning across a namespace at a glance:

./rightsizing/scripts/rightsizing-report.sh payments

Measure net spend with OpenCost (CUR-based) — see docs/opencost-vs-kubecost.md:

helm install opencost opencost/opencost -n opencost -f cost-tools/opencost/values.yaml

Documentation

Why this matters

On EKS the bill is mostly EC2, and EC2 waste comes from three habits: nodes sized for peak and never consolidated, x86 chosen by default, and requests set once and never revisited. Each lever here attacks one of those habits, and they compound — but only if you can measure the result, which is why the tooling comparison is part of the repo rather than an afterthought.

See the companion eks-cost-governance-toolkit for the policy-as-code guardrails and per-team budgets that keep these savings from eroding, and aws-finops-analytics-pack for the AWS-side analytics that consumes the same team / cost-center attribution keys.

License

MIT © Pradeep Maddi

About

EKS cost optimization patterns: Karpenter Spot-first NodePools + consolidation, Graviton (arm64) migration, recommendation-only VPA rightsizing, and OpenCost vs. Kubecost with CUR net pricing. Sanitized.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages