Taints
Taints are the labels we apply to a node to repel pods from being scheduled on it. Think of it like a "do not enter" sign on a node.
The following command is used to apply a taint to a specific node in a Kubernetes cluster.
In the above command,
- <node-name>: This refers to the name of the node you want to taint.
- <key>=<value>: This defines the actual taint itself. It consists of a key (identifier) and a value. These can be freely chosen but should be descriptive for clarity. For example,
type=web - <effect>: This specifies how the taint affects pods that don't have a toleration for it. There are three possible effects:
- NoSchedule
- PreferNoSchedule
- NoExecute
For example,
The Three Taint Effects
The following image illustrates the three taint effects.
Let's understand the meaning of each taint effect.
NoSchedule: Pods that do not tolerate the taint will not be scheduled on the node. Pods already running on the node are not affected.PreferNoSchedule: It's a softer version of NoSchedule. The scheduler will try to avoid scheduling non-tolerant pods on the node, but it's not guaranteed. For instance, if the cluster nodes are already overloaded the scheduler might resort to scheduling the non-tolerant pod on thePreferNoSchedulenode as a last resort.NoExecute: When a taint with theNoExecuteeffect is added to a node, any pods that do not tolerate the taint will be immediately evicted from the node.