Taints are set on nodes.
Tolerations are set on pods.Taints and tolerations do not tell the pod to go to a particular node. They restrict nodes from accepting pods that do not have the matching toleration.
Tolerations are set on pods.Taints and tolerations do not tell the pod to go to a particular node. They restrict nodes from accepting pods that do not have the matching toleration.
Concept
Taints and tolerations ensure that pods are scheduled onto the right nodes by setting restrictions on nodes so that they only accept pods with certain tolerations. For example, assume you have Node 1 and Node 2 and three pods: Pod 1, Pod 2, and Pod 3. If you set a taintapp=green on Node 1, then Node 1 will only accept pods that have the toleration app=green. To schedule Pod 1 on Node 1, you must add the toleration app=green to Pod 1.
Pod 2 and Pod 3 will not be scheduled on Node 1 because they lack the required toleration. Node 2 has no taints, so any pod can be scheduled there — including Pod 1, which is not required to run on Node 1 just because it has a toleration.
Steps
Taint the node
Apply a taint to the node using The taint effect defines what happens to pods that do not tolerate the taint:
kubectl taint nodes.| Effect | Behavior |
|---|---|
NoSchedule | The pod will not be scheduled onto the node. |
PreferNoSchedule | The scheduler tries to avoid placing an intolerant pod on the node, but it is not guaranteed. |
NoExecute | Intolerant pods already running on the node are evicted. New intolerant pods will not be scheduled. |