Interview Prep/Real-World Interview/Kubernetes cluster-level

A node upgrade is stuck; `kubectl drain` loops on "error when evicting pods/"api-6d9-x2k" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget."

IntermediateTroubleshootingKubernetes cluster-level
Answer

Likely causes → The PodDisruptionBudget allows zero voluntary disruptions. Typical cases: a single-replica Deployment with minAvailable: 1, maxUnavailable: 0, or replicas that are already unhealthy so the budget has no room.

Diagnose →

kubectl get pdb -A
kubectl get pdb api -n prod -o jsonpath='{.status}' | jq   # disruptionsAllowed: 0
kubectl get deploy api -n prod

Fix → Scale the Deployment up so one pod can move (kubectl scale deploy api --replicas=3), fix unhealthy replicas, or relax the PDB to maxUnavailable: 1. Don't use --disable-eviction on production workloads unless you accept the outage.

Prevent → Lint PDBs in CI (no PDB that allows zero disruptions with replicas ≤ minAvailable), run critical services with at least 2–3 replicas, and set unhealthyPodEvictionPolicy: AlwaysAllow so crash-looping pods don't block drains.

All Real-World Interview questions Roadmap: Interview readiness

More on Kubernetes cluster-level