Taints and Tolerations
A Node may refuse one Pod and happily take in another, and it can even throw out Pods that were already running there. What decides which Pod it takes in, which one it keeps and which one it sends away?
Play the animation 6 steps, animated, plays on a computer or a tablet
Taints and Tolerations, step by step
-
A taint on the Node object carries a key, an optional value, and an effect. Node-1 gets dedicated=db:NoSchedule in spec.taints. Nothing on the Node changes, because NoSchedule acts at scheduling time and says nothing about the Pods already bound to it.
Play from step 1 -
A toleration is the matching field on the Pod. It matches when the keys are equal and the effects are equal, and the operator decides the value. Equal compares it, Exists ignores it. The toleration on Pod db-1 leaves the effect empty, so it matches every effect on that key. Pod web-1 has none.
Play from step 2 -
Pod web-2 carries no toleration, so the TaintToleration filter plugin drops Node-1 before scoring. Pod web-2 is marked Unschedulable and gets a FailedScheduling event. Nothing reaches the Node, and Pod web-1 keeps running untouched, because it was bound before the taint arrived.
Play from step 3 -
The taint is rewritten with PreferNoSchedule. The same mismatch is now scored rather than filtered. The plugin marks Node-1 down among the Nodes that fit but does not remove it, so Pod web-2 can still land here. The control plane tries to avoid that and does not guarantee it.
Play from step 4 -
A second taint, dedicated=db:NoExecute, is added. This effect is the only one that acts on Pods already running, so the taint-eviction-controller deletes Pod web-1 and Pod web-2, since neither tolerates it. Pod db-1 does, and with no tolerationSeconds this taint never evicts it.
Play from step 5 -
A NoExecute toleration may carry tolerationSeconds, and then the Pod stays that many seconds after the taint lands before eviction. If a Pod sets no toleration for a built-in not-ready or unreachable taint, it gets 300 seconds per such taint. That is the few minutes on the Node Failure and Pod Recovery card.
Play from step 6