The Complete Guide to Kubernetes Cost Optimization in 2026
Kubernetes clusters can burn through budget fast. Right-sizing, scheduling, and spot instances can cut costs 50-70% without sacrificing reliability.
The Cost Problem
A typical misconfigured cluster:
- CPU requests 3x actual usage
- Memory requests 2x actual usage
- No spot/preemptible instances
- Over-provisioned node pools
- No Vertical Pod Autoscaler
Right-Sizing with VPA and HPA
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: my-app-vpa
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: my-app
updatePolicy:
updateMode: "Auto"
VPA analyzes actual resource usage and updates requests automatically.
Spot Instances for Stateless Workloads
nodeSelector:
node.kubernetes.io/lifecycle: spot
tolerations:
- key: "node.kubernetes.io/lifecycle"
operator: "Equal"
value: "spot"
effect: "NoSchedule"
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: "In"
values: ["my-app"]
topologyKey: "kubernetes.io/hostname"
Always combine spot with pod anti-affinity and proper disruption budgets.
Cluster Autoscaler Configuration
apiVersion: autoscaling.k8s.io/v1
kind: ClusterAutoscaler
metadata:
name: default
spec:
scaleDown:
enabled: true
delayAfterAdd: 10m
delayAfterDelete: 0s
delayAfterFailure: 3m
unneededTime: 5m
饮料:
maxNodesTotal: 50
minNodes: 2
cloudProvider: gce
Monitoring with kubecost
Install Kubecost for real-time cost visibility:
kubectl apply -f https://github.com/kubecost/cost-analyzer-helm-chart/releases/latest/download/kubecost.yaml
You'll get namespace-level, deployment-level, and pod-level cost attribution.
Practical Optimization Checklist
- Set CPU/memory requests to match actual usage (use VPA)
- Use spot instances for stateless, fault-tolerant workloads
- Enable cluster autoscaler with appropriate min/max
- Use node pool bin-packing aggressively
- Set resource limits to prevent runaway containers
- Implement pod disruption budgets for availability
- Schedule non-critical batch jobs during off-peak
Conclusion
Kubernetes cost optimization is ongoing. Use VPA for right-sizing, spot instances aggressively, and always monitor with Kubecost. A 60% cost reduction is achievable with proper configuration.
Simplify your infrastructure management — deploy to Kubernetes without the cost optimization headache.
Top comments (0)