How would you design a cost optimization strategy for a Kubernetes-based platform running on AWS EKS that currently spends $500K/month? Target: 30% reduction without impacting reliability.
Quick Answer
Combine Spot instances for stateless workloads (40-60% savings), right-size pods with VPA, use Karpenter for bin-packing, Reserved Instances for baseline, and eliminate idle resources.
Detailed Answer
Cost Optimization Framework (Target: $150K/month savings)
Tier 1: Quick Wins (Week 1-2, ~$50K savings) - Right-size pods: Deploy VPA in recommend mode, identify over-provisioned pods. Most pods request 2-4x what they use. - Delete idle resources: Unused EBS volumes, unattached EIPs, idle load balancers, orphaned snapshots - Scale down non-prod: Dev/staging clusters scale to zero nights/weekends (saves ~60% of non-prod cost) - S3 lifecycle policies: Move infrequently accessed data to S3-IA/Glacier
Tier 2: Compute Optimization (Week 3-6, ~$70K savings) - Spot instances: Run stateless workloads (web servers, workers) on Spot (60-90% discount). Use Karpenter with diversified instance types for availability. - Karpenter over Cluster Autoscaler: Better bin-packing, faster scaling, automatic instance type selection - Graviton instances: ARM-based instances are 20% cheaper with equal or better performance - Reserved Instances / Savings Plans: 1-year commitment for baseline (always-on) capacity. Covers 40-60% of total compute.
Tier 3: Architecture Changes (Week 7-12, ~$30K savings) - Data transfer optimization: Keep services in same AZ where possible, use VPC endpoints instead of NAT Gateway for AWS services - Caching layer: Add Redis/ElastiCache to reduce database load and RDS costs - Serverless for bursty workloads: Move event-driven workloads to Lambda - Container image optimization: Smaller images = faster pulls = less EBS IOPS
Governance
- Kubecost or OpenCost for per-team cost allocation - Tag everything, chargeback to teams - Set resource quota per namespace - Weekly cost review in engineering standup
Code Example
# Karpenter NodePool for cost optimization
apiVersion: karpenter.sh/v1beta1
kind: NodePool
spec:
template:
spec:
requirements:
- key: karpenter.sh/capacity-type
operator: In
values: ["spot", "on-demand"]
- key: kubernetes.io/arch
operator: In
values: ["arm64", "amd64"]
- key: node.kubernetes.io/instance-type
operator: In
values: ["m7g.xlarge", "m6g.xlarge", "c7g.xlarge", "r7g.xlarge"]
nodeClassRef:
name: default
limits:
cpu: "1000"
disruption:
consolidationPolicy: WhenUnderutilizedInterview Tip
Structure your answer in tiers: quick wins, medium-term optimization, and architectural changes. Always quantify expected savings. Mention governance (Kubecost, tagging, chargeback) — that's what separates staff answers from senior answers.