A pod is stuck in 'Pending' state. You run 'kubectl describe pod mypod' and see: '0/4 nodes are available: 4 node(s) didn't match pod anti-affinity constraints'. What does this mean?
Pod anti-affinity enforces that a pod cannot share a topology domain with other pods that match a specified label selector. If the pod's `requiredDuringSchedulingIgnoredDuringExecution` anti-affinity rule targets pods that appear on every node within the cluster, then each node is disqualified and the scheduler reports something like `0/3 nodes are available: 3 node(s) didn't match pod anti-affinity rules.` This exactly matches the described output, confirming the conflict with existing pods is the cause of the Pending state.
Why this answer
The error message '4 node(s) didn't match pod anti-affinity constraints' directly indicates that the pod's anti-affinity rule (defined in the pod spec under `affinity.podAntiAffinity`) prevents it from being scheduled on any node because the rule conflicts with the labels of existing pods on all nodes. Anti-affinity ensures the pod is not co-located with certain pods, and if every node already hosts a pod matching the anti-affinity selector, no node is eligible. This is distinct from taints, node selectors, or resource shortages.
Exam trap
The CKA exam often tests the distinction between anti-affinity, taints/tolerations, and node selectors; the trap here is that candidates misread 'anti-affinity constraints' as a generic scheduling failure and incorrectly choose resource exhaustion or taints.
How to eliminate wrong answers
Option A is wrong because taints and tolerations produce a message like 'node(s) had taints that the pod didn't tolerate', not an anti-affinity constraint error. Option B is wrong because a node selector mismatch yields 'node(s) didn't match node selector', not anti-affinity. Option D is wrong because resource exhaustion shows messages like 'Insufficient cpu' or 'Insufficient memory', not a constraint-based failure.