Stage 5, Part 3 of 9, Scheduling Deep Dive

Text

PART 3: PRODUCTION FAILURE MODES

18. Top 10 Scheduling Failures

#FailureSymptomRoot CauseFix
1Pod stays Pendingkubectl get pods shows PendingNo node matches constraintsCheck describe Events
2Anti-affinity deadlockPods stuck PendingRequired anti-affinity + replicas > nodesUse preferred or add nodes
3Resource fragmentationNodes show free resources but Pods PendingFragmentation (no node has enough of a single resource)Bin-pack or add larger nodes
4Taint not toleratedPods PendingMissing tolerationAdd toleration
5PDB blocks drainNode drain hangsPDB too strictAdjust PDB or add nodes
6Scheduler overloadSlow schedulingToo many PodsScale scheduler, reduce churn
7Priority inversionLow-priority Pods preemptedWrong priority classesFix priorities
8Topology spread deadlockPods PendingmaxSkew too strictRelax maxSkew
9Volume binding delayPods stuck PendingPV in different zoneUse WaitForFirstConsumer
10Scheduler cache inconsistencyPods scheduled on full nodesStale cacheRestart 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 MessageMeaningFix
0/10 nodes are available: 5 Insufficient cpuResource shortageAdd nodes or reduce requests
node(s) had taint {key: value}, that the pod didn't tolerateTaint not toleratedAdd toleration
node(s) didn't match Pod's node affinityAffinity mismatchCheck labels
node(s) didn't match pod anti-affinity rulesAnti-affinity conflictRelax or add nodes
node(s) had volume node affinity conflictPV in wrong zoneUse WaitForFirstConsumer
pod has unbound immediate PersistentVolumeClaimsPVC not boundCheck PVC/StorageClass
0/10 nodes are available: 10 node(s) were unschedulableAll nodes cordonedUncordon

20. Blast Radius Analysis

What Happens When Scheduling Fails?

ComponentImpactSeverity
All new Pods PendingService can't scaleSEV-1
Single Pod PendingDegraded capacitySEV-2
Scheduler downAll new Pods PendingSEV-1
Node drain blocked by PDBUpgrade stuckSEV-2
Wrong priorityPreemption outagesSEV-2
FragmentationWasted capacitySEV-3

Mitigation Strategies

StrategyImplementation
Multiple scheduler replicasHA scheduling
Topology Spread (not Anti-Affinity)Better performance
Preferred over RequiredFlexibility
PDB designEnsure drainability
PriorityClassesClear priorities
DeschedulerRebalance

1:1 copy of the class Google Doc, code in code blocks.