Kubernetes 101 : A short example of Taints and Tolerations



Taints and toleration are two kubernetes concepts used to keep pods from being schedules on certain nodes. 

We assign taints to nodes. We could assign the NoSchedule  parameter to a taint for example.

For pods to be able to be scheduled on tainted node, their toleration need to match the taint o f the node 

To display the node on a cluster, we use the below commands:


We run a one replica of the nginx pod using the below command:


The pod is running on the node-1as we can see form the below ouput:


The name of the pod starts with the deployment's name followed by a random hash.

Remark:

To get the name of the pod, we use the below command:


Tolerations are a pod's characteristic that allows it to be scheduled on "tainted" nodes.

The tolerations we see in the pod's description means that if the pod's state is not ready for more than 300 seconds it is evicted from the node - not executed -.

The DefaultTolerationSeconds admission controller plugin handles the above toleration.

To taint to the first node, we run the following command:


We set the action as NoExecute, and the toleration "key, value" pair as "taint1, true". 
Our pods needs to "tolerate" the node's taint to be able to run on it - set in the toleration section of the Yaml file of the pod -.

Below is a Yaml file of a "tolerating" pod:


The key - taint1 - and effect - NoExecute - of the pod's toleration need to match the taint of the node in order to be able to run on it.

Comments

Leave as a comment:

Archive