How does the Vertical Pod Autoscaler Eviction API update pod CPU/RAM without down time?
❓ Interview Prompt: Explain VPA internals — Recommender, Updater, Admission Plugin components, eviction-based resource updates, and in-place pod resizing in K8s 1.27+.
VPA (Vertical Pod Autoscaler) automatically right-sizes container CPU/memory requests and limits based on historical usage patterns.
VPA Components:
status.recommendation.Why Eviction (Not In-Place):
Before K8s 1.27, resource changes required pod restart (container restart = resource update). The VPA Updater evicts gracefully (respecting PDBs).
In-Place Pod Resource Resizing (K8s 1.27+):
K8s 1.27 introduced InPlacePodVerticalScaling feature — VPA can update CPU/RAM without eviction for changes that don't require container restart. Memory increases are generally safe; memory decreases may still require restart.
Code Implementation Example
# VPA in Auto mode — recommends AND applies resource updates
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: api-vpa
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: api
updatePolicy:
updateMode: "Auto" # Recommender + Updater both active
# updateMode: "Initial" # Only apply on pod creation (no evictions)
# updateMode: "Off" # Recommend only, no changes
resourcePolicy:
containerPolicies:
- containerName: api
minAllowed:
cpu: 100m # never go below 100m CPU
memory: 128Mi
maxAllowed:
cpu: 4000m # never exceed 4 CPU cores
memory: 8Gi
controlledResources:
- cpu
- memory
controlledValues: RequestsAndLimits # update both requests and limits
# Check VPA recommendations
# kubectl describe vpa api-vpa
# Recommendation:
# Container Recommendations:
# Container Name: api
# Target:
# Cpu: 250m ← VPA's current recommendation
# Memory: 512MiVPA Recommender analyzes usage → Updater evicts under/over-provisioned pods → Admission Plugin injects optimal resources at creation. In-place resize (K8s 1.27+) avoids evictions for CPU/memory changes.