Amazon EKS — Project 5 — Cost Optimization

1 minute read

Project 5 — EKS Cost Optimization

Reduce your EKS bill by 40-70% with Spot instances, right-sizing, Karpenter, and scheduling.


Cost Breakdown

Typical EKS Costs
┌─────────────────────────────────────────────┐
│                                             │
│  EC2 Instances (Nodes)          60-70%      │
│  ████████████████████████████               │
│                                             │
│  EBS Storage                    10-15%      │
│  ███████                                    │
│                                             │
│  Data Transfer                  5-10%       │
│  ████                                       │
│                                             │
│  EKS Control Plane              $72/month   │
│  ██                                         │
│                                             │
│  Load Balancers                 5-10%       │
│  ████                                       │
│                                             │
└─────────────────────────────────────────────┘

Strategy 1: Spot Instances (60-90% Savings)

# Karpenter NodePool with Spot
apiVersion: karpenter.sh/v1beta1
kind: NodePool
metadata:
  name: spot-pool
spec:
  template:
    spec:
      requirements:
        - key: karpenter.sh/capacity-type
          operator: In
          values: ["spot"]
        - key: karpenter.k8s.aws/instance-category
          operator: In
          values: ["c", "m", "r"]
        - key: karpenter.k8s.aws/instance-generation
          operator: Gt
          values: ["4"]
  disruption:
    consolidationPolicy: WhenUnderutilized

Strategy 2: Right-Sizing with VPA

# Install VPA in recommendation mode
# Then check recommendations after 24h:
$ kubectl describe vpa web-vpa

# Typical finding:
# Requested: 500m CPU, 512Mi memory
# Actual usage: 50m CPU, 128Mi memory
# → 10x over-provisioned!

Strategy 3: Schedule Non-Production

# Scale dev/staging to zero at night
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: dev-scaler
spec:
  scaleTargetRef:
    name: dev-app
  minReplicaCount: 0
  maxReplicaCount: 5
  triggers:
    - type: cron
      metadata:
        timezone: America/New_York
        start: 0 8 * * 1-5    # Scale up 8 AM weekdays
        end: 0 20 * * 1-5     # Scale down 8 PM weekdays
        desiredReplicas: "3"

Strategy 4: Savings Plans

Type Savings Commitment
Compute Savings Plan (1yr, no upfront) 20-30% Flexible instance types
Compute Savings Plan (3yr, all upfront) 40-50% Locked for 3 years
Spot Instances 60-90% Can be interrupted

Cost Optimization Checklist

Action Savings Effort
Right-size pods (VPA) 20-40% Low
Use Spot for stateless workloads 60-90% Medium
Karpenter consolidation 20-30% Low
Schedule dev/staging shutdown 60% on non-prod Low
Use Graviton (ARM) instances 20% Medium
Savings Plans 20-50% Low

What You Practiced

  • Spot instance strategies with Karpenter
  • VPA-based right-sizing
  • Schedule-based scaling with KEDA
  • Cost monitoring and allocation

What’s Next?

More challenges: Practice Projects Exercises.