Stage 5, Part 3 of 9, Scheduling Deep Dive
Text
PART 3: PRODUCTION FAILURE MODES
18. Top 10 Scheduling Failures
| # | Failure | Symptom | Root Cause | Fix |
| 1 | Pod stays Pending | kubectl get pods shows Pending | No node matches constraints | Check describe Events |
| 2 | Anti-affinity deadlock | Pods stuck Pending | Required anti-affinity + replicas > nodes | Use preferred or add nodes |
| 3 | Resource fragmentation | Nodes show free resources but Pods Pending | Fragmentation (no node has enough of a single resource) | Bin-pack or add larger nodes |
| 4 | Taint not tolerated | Pods Pending | Missing toleration | Add toleration |
| 5 | PDB blocks drain | Node drain hangs | PDB too strict | Adjust PDB or add nodes |
| 6 | Scheduler overload | Slow scheduling | Too many Pods | Scale scheduler, reduce churn |
| 7 | Priority inversion | Low-priority Pods preempted | Wrong priority classes | Fix priorities |
| 8 | Topology spread deadlock | Pods Pending | maxSkew too strict | Relax maxSkew |
| 9 | Volume binding delay | Pods stuck Pending | PV in different zone | Use WaitForFirstConsumer |
| 10 | Scheduler cache inconsistency | Pods scheduled on full nodes | Stale cache | Restart scheduler |
19. Scheduling Debugging Runbook
"Pod is Pending" — Step-by-Step
text
STEP 1: Confirm Pending
$ kubectl get pod <pod>
# STATUS = Pending
STEP 2: Describe the Pod (this is the source of truth)
$ kubectl describe pod <pod>
# Read Events section
STEP 3: Look for FailedScheduling events
# Events show exactly why scheduling failed
STEP 4: Categorize the issue
"Insufficient cpu/memory" → Resource issue
- Check node resources
- $ kubectl describe nodes | grep -A5 "Allocated resources"
"node(s) had taint" → Taint issue
- Check node taints
- $ kubectl describe node <node> | grep Taints
- Add toleration
"node(s) didn't match node selector" → Node selector/affinity issue
- Check node labels
- $ kubectl get nodes --show-labels
- Verify nodeSelector/affinity matches
"node(s) didn't match pod affinity" → Pod affinity issue
- Check if matching Pods exist
- $ kubectl get pods -l <selector>
"node(s) didn't match pod anti-affinity" → Anti-affinity issue
- Too strict for cluster size
- Relax to preferred
"node(s) exceed max volume count" → Volume limit
- Check node's volume limit
- Consider larger instance type
"waiting for ephemeral volume" → Volume binding issue
- Check PVC
- $ kubectl get pvc
STEP 5: Check nodes
$ kubectl get nodes
# Any NotReady? Any cordoned?
$ kubectl describe nodes | grep -A5 "Allocated resources"
STEP 6: Check priority classes
$ kubectl get pod <pod> -o jsonpath='{.spec.priorityClassName}'
$ kubectl get priorityclasses
STEP 7: Check PDBs
$ kubectl get pdb -A
$ kubectl describe pdb <name>
STEP 8: Try removing constraints (test)
# Remove nodeSelector temporarily to isolate
STEP 9: Escalate
Common Error Messages → Meaning
| Error Message | Meaning | Fix |
0/10 nodes are available: 5 Insufficient cpu | Resource shortage | Add nodes or reduce requests |
node(s) had taint {key: value}, that the pod didn't tolerate | Taint not tolerated | Add toleration |
node(s) didn't match Pod's node affinity | Affinity mismatch | Check labels |
node(s) didn't match pod anti-affinity rules | Anti-affinity conflict | Relax or add nodes |
node(s) had volume node affinity conflict | PV in wrong zone | Use WaitForFirstConsumer |
pod has unbound immediate PersistentVolumeClaims | PVC not bound | Check PVC/StorageClass |
0/10 nodes are available: 10 node(s) were unschedulable | All nodes cordoned | Uncordon |
20. Blast Radius Analysis
What Happens When Scheduling Fails?
| Component | Impact | Severity |
| All new Pods Pending | Service can't scale | SEV-1 |
| Single Pod Pending | Degraded capacity | SEV-2 |
| Scheduler down | All new Pods Pending | SEV-1 |
| Node drain blocked by PDB | Upgrade stuck | SEV-2 |
| Wrong priority | Preemption outages | SEV-2 |
| Fragmentation | Wasted capacity | SEV-3 |
Mitigation Strategies
| Strategy | Implementation |
| Multiple scheduler replicas | HA scheduling |
| Topology Spread (not Anti-Affinity) | Better performance |
| Preferred over Required | Flexibility |
| PDB design | Ensure drainability |
| PriorityClasses | Clear priorities |
| Descheduler | Rebalance |
1:1 copy of the class Google Doc, code in code blocks.