Interview Prep/Kubernetes/Cluster operations: certs, drains, rollouts and quotas

`kubectl drain` loops on `error when evicting pods/"web-6d8f-k2x9q" -n "prod" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.`

IntermediateTroubleshootingCluster operations: certs, drains, rollouts and quotas
Answer

Likely causes → The PDB allows zero disruptions right now: minAvailable equals the replica count (or maxUnavailable: 0), a single-replica Deployment with minAvailable: 1, or some replicas are already unhealthy so the budget is used up.

Diagnose →

kubectl get pdb -n prod
# NAME  MIN AVAILABLE  MAX UNAVAILABLE  ALLOWED DISRUPTIONS
# web   3              N/A              0
kubectl get deploy web -n prod
kubectl get pods -n prod -l app=web -o wide

Fix → Scale the Deployment up by one so a Pod can move, or fix the unhealthy replicas. If the PDB is simply wrong, change it to maxUnavailable: 1. Avoid --disable-eviction except in emergencies; it bypasses PDBs entirely.

Prevent → Policy: PDBs must allow at least one disruption, and workloads with PDBs must have 2+ replicas. Set unhealthyPodEvictionPolicy: AlwaysAllow so broken Pods do not block drains.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Cluster operations: certs, drains, rollouts and quotas