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.
More on Kubernetes cluster-level
Every `kubectl` command fails with "The connection to the server 10.0.1.10:6443 was refused - did you specify the right host or port?"BeginnerA new deployment's pods stay Pending with "0/5 nodes are available: 5 Insufficient cpu. preemption: 0/5 nodes are available: 5 No preemption victims found for incoming pod."BeginnerPods are Pending, but Cluster Autoscaler won't add nodes; the pod events say "pod didn't trigger scale-up: 2 node(s) didn't match Pod's node affinity/selector, 1 max node group size reached".IntermediateA node goes NotReady and kubelet logs "PLEG is not healthy: pleg was last seen active 3m10s ago; threshold is 3m0s".IntermediateAfter a node was terminated, its pods have shown `Terminating` for two hours and their replacements aren't being created.IntermediateYou deleted a namespace an hour ago and it's still `Terminating`.Intermediate