session

~/chopper

article

Taints, tolerations, and node affinity

Taint and Toleration is a restriction mechanism in Kubernetes that controls which pods can be assigned onto specific nodes. Taints are applied to prevent unwanted pods from being scheduling. Taint is defined as a key-value pair with an associated effect. There are three taint effects: NoSchedule, PreferNoSchedule and NoExecute. NoSchedule effect prevents pods without a matching toleration from being scheduled onto the nodes. PreferNoSchedule avoids scheduling pods onto the nodes unless no other options are available. NoExecute effect removes any existing pods on the node that do not tolerate the taint.

Node Affinity

Node Affinity ensures that pods are running on specific nodes which are matched with node selectors defined in configuration of the pod. There are three types of Node affinity

  • RequiredDuringSchedulingIgnoredDuringExecution,
  • PreferredDuringSchedulingIgnoredDuringExecution
  • RequiredDuringSchedulingRequiredDuringExecution

The process of scheduling pod is ignored if there is no node matched with the Node Affinity and ignore re-scheduling even if there are any changes within the pods after scheduling in RequiredDuringSchedulingIgnoredDuringExecution.

With PreferredDuringSchedulingIgnoredDuringExecution, Pods are scheduled onto the appropriate nodes unless there is no node matched with the Node Affinity. It also ignores any changes of the pods after scheduling process is completed.

Using RequiredDuringSchedulingRequiredDuringExecution, only nodes that are matched with the Node Affinity are assigned the pods, otherwise it won’t schedule the pods. Rescheduling is processed if there are any changes for the pods after scheduling.