You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above taint has key=thisnode, value=HatesPods and effect as NoSchedule. These key value pairs are configurable. Any pod that doesn't have a matching toleration to this taint will not be scheduled on node1.
28
+
29
+
To remove the above taint, we can run the following command
* NoSchedule - Doesn't schedule a pod without matching tolerations
36
+
* PreferNoSchedule - Prefers that the pod without matching toleration be not scheduled on the node. It is a softer version of NoSchedule effect.
37
+
* NoExecute - Evicts the pods that don't have matching tolerations.
38
+
39
+
A node can have multiple taints.
40
+
For example, if any pod is to be scheduled on a node with multiple *NoExecute* effect taints, then that pod must tolerate all the taints. However, if the set of taints on a node is a combination of *NoExecute* and *PreferNoExecute* effects and the pod only tolerates *NoExecute* taints then kubernetes will prefer not to schedule the pod on that node, but will do it anyway if there's no alternative.
41
+
42
+
### Tolerations
43
+
Nodes are tainted for a simple reason, to avoid running of workload. The similar outcome can be achieved by PodAffinity/PodAnti-Affinity, however, to reject a large workload taints are more efficient (In a sense that they only require tolerations to be added to the small workload that does run on the tainted nodes as opposed to podAffinity which would require every pod template to carry that information)
44
+
45
+
Toleration is simply a way to overcome a taint.
46
+
47
+
For example,
48
+
In the above section, we have tainted thisnode.compute.infracloud.io
49
+
50
+
To schedule the pod on that node, we need a matching toleration. Below is the toleration that can be used to overcome the taint.
51
+
52
+
```
53
+
tolerations:
54
+
- key: "thisnode"
55
+
operator: "Equal"
56
+
value: "HatesPods"
57
+
effect: "NoSchedule"
58
+
```
59
+
60
+
What we are telling kubernetes here is that, on any node if you find that there's a taint with key *node1* and its value is *HatesPods* then that particular taint should not stop you from scheduling this pod on that node.
61
+
62
+
Toleration generally has four parts. A key, a value, an operator and an effect.
63
+
Operator, if not specified, defaults to *Equal*
64
+
65
+
## Use cases
66
+
* Taints can be used to group together a set of Nodes that only run a certain set of workload, like network pods or pods with special resource requirement.
67
+
* Taints can also be used to evict a large set of pods from a node using taint with *NoExecute* effect.
68
+
69
+
## Examples:
70
+
Follow through guide.
71
+
72
+
Let's begin with listing nodes.
73
+
74
+
```
75
+
kubectl get nodes
76
+
```
77
+
You should be able to see the list of nodes available in the cluster,
You should be able to see that some of the pods are scheduled on node1 and some on node2. However, no pod is scheduled on node3. This is because, in the new deployment spec, we are tolerating taint *NoSchedule* effect. node3 is tainted with *NoExecute* effect which we have not tolerated so no pods will be scheduled there.
0 commit comments