Amazon EKS — VPA — Vertical Pod Autoscaler

1 minute read

Vertical Pod Autoscaler (VPA)

VPA recommends or automatically adjusts CPU and memory requests/limits for pods based on actual usage.


VPA Modes

Mode Behavior
Off Only generates recommendations (no changes)
Initial Sets resources at pod creation only
Auto Evicts and recreates pods with new resources

Install VPA

$ git clone https://github.com/kubernetes/autoscaler.git
$ cd autoscaler/vertical-pod-autoscaler
$ ./hack/vpa-up.sh

VPA Configuration

apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: web-vpa
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: web
  updatePolicy:
    updateMode: "Off"     # Recommendation-only (safest to start)
  resourcePolicy:
    containerPolicies:
      - containerName: web
        minAllowed:
          cpu: 50m
          memory: 64Mi
        maxAllowed:
          cpu: 2
          memory: 2Gi

Check Recommendations

$ kubectl describe vpa web-vpa
  Recommendation:
    Container Recommendations:
      Container Name: web
      Lower Bound:
        Cpu:     25m
        Memory:  128Mi
      Target:
        Cpu:     100m
        Memory:  256Mi
      Upper Bound:
        Cpu:     500m
        Memory:  512Mi

Best practice: Start with Off mode, review recommendations, then apply manually or switch to Auto.


HPA + VPA

Approach Works?
HPA (CPU) + VPA (memory) ✅ Yes — different metrics
HPA (CPU) + VPA (CPU) ❌ No — they’ll conflict

Common Mistakes

Mistake Impact
VPA Auto mode + HPA on same metric They fight each other
No min/max bounds VPA might set absurd values
Starting with Auto mode Unexpected pod restarts

What’s Next?

Scale the nodes: Cluster Autoscaler.