Bitzu

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

Single choice

What does nodeSelector in a Pod spec match against?

  1. Node labels
  2. Container image names
  3. Namespace quotas
  4. 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.

Select all that apply

Which of these influence where a Pod is scheduled?

  1. nodeSelector
  2. Pod anti-affinity
  3. Topology spread constraints
  4. ResourceQuota
  5. 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.

True or false

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.

Download on the App StoreGet it on Google Play

More KCNA topics in this module