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,

  1. <node-name>: This refers to the name of the node you want to taint.
  2. <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
  3. <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.

  1. NoSchedule: Pods that do not tolerate the taint will not be scheduled on the node. Pods already running on the node are not affected.
  2. 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 the PreferNoSchedule node as a last resort.
  3. NoExecute: When a taint with the NoExecute effect is added to a node, any pods that do not tolerate the taint will be immediately evicted from the node.

Complete and Continue