Fix GCP GKE Vpa Update Errors
When working with GCP GKE, you may encounter a configuration error that prevents your deployment from working. This guide explains the most common mistake with vpa update and shows the exact fix.
A Common Mistake
Creating a VerticalPodAutoscaler (VPA) in UpdateMode auto without a PodDisruptionBudget, causing pod evictions that disrupt service.
The incorrect command:
kubectl apply -f - <<EOF
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: my-app-vpa
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: my-app
updatePolicy:
updateMode: "Auto"
EOF
Error output:
vpa.autoscaling.k8s.io/my-app-vpa created
VPA evicts pods to apply new resource recommendations:
kubectl get events
LAST SEEN TYPE REASON OBJECT
10s Normal EvictByVPA pod/my-app-xxxxx
30s Normal EvictByVPA pod/my-app-yyyyy
Without PDB, multiple pods can be evicted simultaneously, causing downtime.
The Correct Approach
The right way to configure vpa update in GCP GKE:
kubectl apply -f - <<EOF
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: my-app-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: my-app
EOF
# Then create VPA with UpdateMode: Auto
Successful result:
pdb.policy/my-app-pdb created
VPA evicts pods one at a time respecting the PDB.
At least 2 pods are always available.
No downtime during VPA updates.
How to Prevent This
Always create a PDB before using VPA in Auto mode. Use Initial mode to apply resource recommendations on pod restart. Use Off mode for dry-run recommendations. VPA works best with HPA when using custom metrics. Monitor VPA recommendations with kubectl describe vpa. VPA requires metrics-server.
FAQ
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Secure your cloud with DodaTech.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro