Kubernetes 101 : Taints and Tolerations
A taint is a node's parameter. Only the pods that have a toleration for that taint could be scheduled on that node.
Below an example of how to "taint" a node:
- master-taint : the name of the node
- is-master="true" : the taint's key and value.
- NoSchedule: the effect of the taint - is-master="true" - on the pods that don't have a "toleration" for it .
Below is the Yaml version of the above command:
We use the "kubectl apply -f file-name.yaml" command to create our objects.
The above pod can be scheduled on a node that is tainted with "key: is-master".
The effect "effect:NoSchedule" is applied to the pods that can't "tolerate" the taint "key: is-master" .
Remark:
- operator: "Exists" : using this option, we don't need to specify the value of the key.
If we use - operator: "Equal" -, we would need to specify a value of the key, as below:
We can have other effects like "effect=PreferNoSchedule", which is more "leniant" than the "effect: NoSchedule".
One use of the "toleration-taint" functions is to prevent the scheduling of pods on the master nodes.
Checking the "taint" of a node:
We can check the taint on our node using the below command:
Comments