QA
Senior LevelDocker & Deployment

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:

1
VPA Recommender: Continuously fetches container metrics from Metrics Server and historical data. Runs a statistical model to compute optimal CPU/RAM requests (targeting ~85th percentile of observed usage). Writes recommendations to VPA object's status.recommendation.
2
VPA Updater: Checks if running pods match VPA recommendations. If a pod's resources are significantly out-of-range, the Updater evicts the pod (using the Eviction API). The pod controller (Deployment/StatefulSet) then recreates the pod.
3
VPA Admission Plugin (Mutating Webhook): When a new pod is created (after eviction or first deployment), the Admission Plugin intercepts it and injects the recommended resource requests/limits into the pod spec before it reaches etcd.

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

yaml
# 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:  512Mi
💡VPA Auto mode: Recommender computes target, Updater evicts out-of-range pods, Admission Plugin injects recommendations on recreate.
🎯 Interview Key Takeaway

VPA 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.

#Kubernetes#VPA#Vertical Autoscaling#Resource Optimization#Eviction API#Senior
Back to all Docker & Deployment Questions→

More Docker & Deployment Interview Questions

Beginner LevelDocker & Deployment

How do Docker Multi-Stage Builds minimize image size and improve security?

Beginner LevelDocker & Deployment

What is the difference between a Docker Container and a Virtual Machine (VM)?

Beginner LevelDocker & Deployment

What is the difference between a Docker Image and a Docker Container?