What VPA Measures and Who Acts
What VPA Measures and Who Acts
HPA answers "how many pods?"; VPA answers "how big should each pod be?". Three components cooperate:
- Recommender reads metrics and history, then writes recommended requests/limits into the VPA object status
- Admission controller injects those values when new pods are created
- Updater evicts running pods whose declared requests deviate from the recommendation, so the admission controller can resize them on the next start
VPA needs metrics-server. Resizing happens by pod eviction — VPA cannot change resources of a running container in place.
Deploying and Reading Recommendations
Deploying and Reading Recommendations
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata: { name: api-vpa }
spec:
targetRef: { apiVersion: apps/v1, kind: Deployment, name: api }
updatePolicy:
updateMode: Auto
containerPolicies:
- containerName: '*'
mode: Auto
minAllowed: { cpu: 100m, memory: 128Mi }
maxAllowed: { cpu: 2, memory: 2Gi }
Inspect the output with kubectl describe vpa api-vpa — it reports recommendedTarget (for new pods) and recommended lower/upper bounds per container. Modes: Off (recommend only), Initial (set once at creation), Auto, and Recreate (evict and resize, ignoring controller refusals).
Pitfalls and Interview Angles
Pitfalls and Interview Angles
HPA conflict. If HPA scales on CPU utilization and VPA changes the CPU request, the utilization ratio shifts under the HPA — a feedback loop with oscillating replica counts. Run VPA in Off mode alongside a CPU HPA, or point the HPA at custom metrics.
Recreate costs availability. updateMode: Recreate evicts pods; without a readiness-gated rollout you take an outage.
Cold recommendations. Until the recommender has usage history its suggestions are conservative or incomplete — expect iterations before values stabilize.
Interview angle: contrast HPA and VPA inputs (replica count vs request size), explain why resizing requires eviction, and describe how you would safely combine both.
Quiz
1. Which VPA component changes resources of running workloads, and how?
2. Why does a CPU-based HPA conflict with VPA on the same deployment?
3. What does updateMode: Off give you?
Flashcards
Question
VPA components
Click to reveal answer
Answer
Recommender computes targets, admission controller injects them at pod creation, updater evicts pods that need resizing.
Question
VPA updateMode values
Click to reveal answer
Answer
Off (status only), Initial (first creation), Auto, Recreate (evict to resize, ignores workload-controller refusal).
Question
Why VPA restarts pods
Click to reveal answer
Answer
Container resource limits are immutable at runtime; eviction is the only way to apply new values.
Question
VPA + HPA rule
Click to reveal answer
Answer
Never drive both from CPU: VPA moves requests, which moves HPA utilization. Use VPA Off or HPA on custom metrics.
Revision Notes
Key Takeaways
- 1. VPA rightsizes requests/limits via recommender, admission controller, and updater
- 2. Resizing requires eviction — plan for restarts and use readiness gates
- 3. CPU-based HPA and VPA on one workload conflict; pick one or split the signals
Interview Tips
- • Name all three VPA components and what each one does before discussing modes
- • Explain the HPA/VPA conflict mathematically: utilization = usage ÷ request, and VPA rewrites the denominator
Cheat Sheet
VPA: recommender→status, admission→new pods, updater→evicts to resize. Modes Off/Initial/Auto/Recreate. Needs metrics-server. Never pair with CPU HPA — requests change under HPA.