Fix GCP GKE Pod Pdb 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 pod pdb and shows the exact fix.
A Common Mistake
Not creating a PodDisruptionBudget (PDB) for a critical application, allowing voluntary disruptions (node upgrades, cluster updates) to cause downtime.
The incorrect command:
# No PDB configured for critical app
kubectl drain node-pool-xxxxx --ignore-daemonsets
Error output:
Node drained.
All pods on the node are evicted simultaneously. The application has no PDB to prevent too many pods from being evicted at once. Users experience downtime:
kubectl get pods
my-app-xxx 0/1 Terminating
my-app-yyy 0/1 Terminating
my-app-zzz 0/1 Pending
The Correct Approach
The right way to configure pod pdb 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
Successful result:
pdb.policy/my-app-pdb created
During node drain:
kubectl get pdb
NAME MIN AVAILABLE CURRENT ALLOWED AGE
my-app-pdb 2 3 5m
Drain blocks until at least 2 pods remain running on other nodes.
How to Prevent This
Create PDBs for all production workloads. Set minAvailable (at least N pods) or maxUnavailable (at most N pods down). PDBs do not prevent voluntary disruptions but control how many can be down simultaneously. Test PDB behavior during maintenance windows. PDBs are essential for multi-zone deployments.
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