A Toleration Lets a Pod onto a Tainted Node, It Doesn't Send It There

In progress Kubernetes

A taint on a node repels pods; a toleration on a pod lets it ignore one taint. That's all a toleration does: it opens the gate, it doesn't choose the node. If an untainted node also fits, the scheduler may put the pod there.

kubectl taint nodes k8s-gpu-01 nvidia.com/gpu=true:NoSchedule
tolerations:
- key: nvidia.com/gpu
  operator: Equal
  value: "true"
  effect: NoSchedule
nodeSelector:
  homelab/media: "true"      # this is what actually sends the pod there
Effect Meaning
NoSchedule No new pods without a toleration; running pods stay.
PreferNoSchedule Avoided if anything else fits.
NoExecute Also evicts running pods without a toleration (Kubernetes uses it for unreachable nodes).

Three Separate Mechanisms

  • Taint + toleration: keep everything else off a node (a GPU node's RAM and GPU stay free for GPU work).
  • nodeSelector / node affinity: pin a pod to labelled nodes.
  • An extended resource request (nvidia.com/gpu: 1): requires a node advertising that resource, but does not get the pod past the taint (the ExtendedResourceToleration admission plugin can add the toleration automatically; it's off in kubeadm).

Placing by a role label instead of the hostname (homelab/media=true rather than kubernetes.io/hostname) means moving a whole stack later is one label change, not an edit per manifest.

References

Review cards

Flashcard A pod tolerates the GPU taint but runs on another node. Why, and what pins it?

A toleration only allows the tainted node; the scheduler can still pick any node that fits. A nodeSelector or node affinity sends it there.

Quiz Which taint effect also evicts running pods that don't tolerate it?
  • NoSchedule
  • PreferNoSchedule
  • NoExecute

NoSchedule only blocks new pods; PreferNoSchedule is a soft preference.

Flashcard Does requesting `nvidia.com/gpu: 1` get a pod past the GPU node's taint?

No. The request requires a node advertising the resource; the taint still needs a toleration (unless the ExtendedResourceToleration admission plugin adds it).