KCNA ยท Cluster administration and scheduling
Scheduling constraints
nodeSelector, node/pod affinity and anti-affinity, taints and tolerations, topology spread.
Key points
- nodeSelector matches Pods to nodes by label.
- Node affinity does the same with richer rules, and pod affinity or anti-affinity places Pods relative to other Pods.
- Taints repel Pods from a node unless the Pod carries a matching toleration (effects: NoSchedule, PreferNoSchedule, NoExecute).
- Topology spread constraints distribute replicas across zones or nodes.
- A toleration only permits placement; it does not attract.
Source: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
Practice questions
What does nodeSelector in a Pod spec match against?
- Node labels
- Container image names
- Namespace quotas
- Service selectors
Show answer
Answer: A. Node labels
nodeSelector is a simple key-value match on node labels. It does not look at taints, Pod names or images.
Which of these influence where a Pod is scheduled?
- nodeSelector
- Pod anti-affinity
- Topology spread constraints
- ResourceQuota
- imagePullPolicy
Show answer
Answer: A. nodeSelector, B. Pod anti-affinity, C. Topology spread constraints
nodeSelector, pod anti-affinity and topology spread constraints all steer placement. ResourceQuota limits namespace totals and imagePullPolicy affects image fetching, not node choice.
Adding a toleration to a Pod makes the scheduler prefer the tainted node.
Show answer
Answer: False
False. A toleration only allows the Pod onto a tainted node; to attract it you need nodeSelector or affinity.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
