Reputation: 765
When defining the Taints & Tolerations, we defined the Taint as below:
kubectl taint nodes node1 key1=value1:NoSchedule
Now any pod that does not have toleration defined as below will not be scheduled on node1. And the one that has toleration defined, gets scheduled on this node. But, why do we need to define NoSchedule on the POD? It is already defined on the node.
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoSchedule"
What impact does it have if:
kubectl taint nodes node1 key1=value1:NoSchedule
tolerations:
- key: "key1"
operator: "Equal"
value: "value1"
effect: "NoExecute"
Note: I understand that it is trying to match not just "taint value" but also the "taint effect". But is there any use case for matching "taint effect" as well?
tolerations.effect (string) Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
Thanks
Upvotes: 7
Views: 1547
Reputation: 1
Note: I understand that it is trying to match not just "taint value" but also the "taint effect". But is there any use case for matching "taint effect" as well?
A use case that I can think of is having a node with taints of both NoSchedule and PreferNoSchedule for the same key
We can then create 3 "types" of pods
It's good to have the control available to you, could be for cost optimisation, could be for tracking resources. In general it's better to have the control and not need it than to need it and not have it
Upvotes: 0
Reputation: 160
I also had the same question, and I stumble on this post. I some of this idea help me understand it:
taint and toleration should work together from the docs 3rd paragrah
the effect describe pod-node relationship so they must have an agreement on what action to take.
What impact does it have if:
The node effect is NoSchedule kubectl taint nodes node1 key1=value1:NoSchedule
But the POD toleration is NoExecute
Thus in this case the pod and node doesn't have agreement on what to do, so it same effect as not having macthing key=value at all, so pod will not be scheduled at all.
why do we need to define NoSchedule on the POD? It is already defined on the node.
you don't need to specify the effect on the pod, if you desire the pod has the same effect as whatever the node has.
But you might want to govern another pod differently, I think it makes more sense when multiple taint and toleration comes into play. Reading example on the above docs help me.
That's what I understand. Let me know if there's any misunderstanding.
Upvotes: 1
Reputation: 15548
What impact does it have if:
- The node effect is NoSchedule
kubectl taint nodes node1 key1=value1:NoSchedule
- But the POD toleration is NoExecute
Pod will not be schedule on the node where it failed to tolerate, eg. your sample pod will not be schedule on node that tainted with NoSchdule
because it only tolerates NoExecute
.
...use case for matching "taint effect"
Not sure what it means here; but it is possible to tolerate a key with any effect by only specified the key and value.
Upvotes: 2