What is kubernetes taint
You can see above our nginx-toleration-demo got scheduled on node kube-worker2.Īn empty key with operator Exists matches all keys, values and effects which means this will tolerate everything.Īn empty effect matches all effects with the specified key.Ī node can have multiple taints and the pod can have multiple tolerations. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
Let us first have a look at the already running pods on the different # kubectl get pods -o wide.Syntax: kubectl taint nodes key=value:effect
We can apply more than one taint to a single node and more than one toleration to a single Pod. NoExecute: If there is at least one un-ignored taint with effect NoExecute then the pod will be evicted from the node (if it is already running on the node), and will not be scheduled onto the node (if it is not yet running on the node). But if there is a pod which tolerates one taint, it can be scheduled. PreferNoSchedule: Kubernetes will try not to schedule the Pod on the node if at least one un-tolerated taint has a PreferNoSchedule effect. But no more pods will be scheduled on this node unless have matching tolerations. Already existing Pods which doesn't tolerate this taint, will not be evicted or deleted from this node.
NoSchedule: if there is at least one un-ignored taint with effect NoSchedule then Kubernetes will not schedule the pod onto that node. Three different values can be assigned to effect: Taints and tolerations working together ensures that pods are not scheduled onto inappropriate nodes. Tolerations are applied to pods, and allow (but do not require) the pods to schedule onto nodes with matching taints. In Kubernetes you can mark (taint) a node so that no pods can be scheduled on that node unless they have explicit tolerations applied. Taints behaves exactly opposite, they allow a node to repel a set of pods. When we use Node affinity (a property of Pods) it attracts them to a set of nodes (either as a preference or a hard requirement). Taints and Toleration functions similarly but take an opposite approach. In the last article we have learnt about Node affinity.