Implementing Vertical Pod Autoscaling
1. Installing VPA Components
git clone https://github.com/kubernetes/autoscaler
cd autoscaler/vertical-pod-autoscaler && ./hack/vpa-up.sh
| Component | Role |
| Recommender | Compute resource recommendations |
| Updater | Evict pods needing new resources |
| Admission Plugin | Mutate pod requests at creation |
2. Creating VPA Resource
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata: { name: web-vpa }
spec:
targetRef: { apiVersion: apps/v1, kind: Deployment, name: web }
updatePolicy: { updateMode: Auto }
resourcePolicy:
containerPolicies:
- containerName: '*'
minAllowed: { cpu: 100m, memory: 128Mi }
maxAllowed: { cpu: "2", memory: 2Gi }
controlledResources: ["cpu","memory"]
3. Setting Update Mode
| Mode | Behavior |
| Off | Only recommendations, no mutation |
| Initial | Set at pod creation only |
| Recreate | Evict to apply new values |
| Auto | Currently same as Recreate; in-place coming |
| InPlaceOrRecreate NEW | 1.30+ in-place pod resize |
4. Configuring Resource Policy
| Field | Use |
| minAllowed / maxAllowed | Bound recommendations |
| controlledResources | cpu, memory |
| controlledValues | RequestsAndLimits / RequestsOnly |
| mode (per container) | Auto / Off |
5. Setting Min Allowed Resources
minAllowed: { cpu: 100m, memory: 128Mi }
6. Setting Max Allowed Resources
maxAllowed: { cpu: "4", memory: 8Gi }
7. Viewing VPA Recommendations
kubectl get vpa web-vpa -o yaml
kubectl describe vpa web-vpa
| Field | Meaning |
| lowerBound | Minimum recommended (avoid eviction) |
| target | Optimal value |
| upperBound | Maximum projected |
| uncappedTarget | Without min/max applied |
8. Understanding VPA Components
VPA Pipeline
metrics → Recommender → VPA.status → Updater → evict pods
↓
Admission Plugin (rewrites new pod requests)
9. Using VPA with HPA
| Combination | Recommendation |
| HPA on CPU + VPA Auto on CPU | Conflicts; avoid |
| HPA on custom metric + VPA on CPU/memory | Safe; complementary |
| VPA Off (recommend-only) + HPA | Use VPA for rightsizing analysis |
10. Deleting VPA Resources
kubectl delete vpa web-vpa
./hack/vpa-down.sh # remove all VPA components