Taints and Tolerations
Taints allow you to repel pods from specific nodes. A node with a taint does not accept any pod that does not explicitly tolerate that taint. Tolerations are applied to pods and allow the scheduler to place those pods on tainted nodes. To add taints and tolerations, see Configure Taints and Tolerations. To remove a taint, see Remove a Taint.
Use taints and tolerations together to:
Reserve nodes for specific workloads, such as memory-heavy batch processing or high-priority services.
Isolate nodes for compliance or security requirements.
Control which workloads run on which node pools in your cluster.
Understanding taints and tolerations
A taint has three components:
Key: An identifier for the taint. Example:
workload. A key consists of a name of up to 63 characters, with an optional prefix in domain name format of up to 253 characters, separated by/. Example:example.com/my-taint.Value: An optional label for the taint. Example:
high-memory. It can be up to 63 characters long.Effect: What happens to pods that do not tolerate the taint. Required. Must be one of
NoSchedule,PreferNoSchedule, orNoExecute.
A toleration matches a taint by key, value and effect. With the Exists operator, the value is not compared. In Managed Kubernetes, you set taints at the node pool level. When you add a taint to a node pool, the taint is applied to all nodes in that pool. You can add up to 50 taints per node pool. You can also apply taints to individual nodes directly using kubectl. See Apply a taint to an individual node.
Taint effects
The effect of a taint determines how the scheduler treats pods without a matching toleration. The following table compares the three effects and their typical use cases:
Effect
Behavior
Use case
NoSchedule
New pods without a matching toleration are not scheduled on this node. Running pods are not evicted, so they continue to run on the node.
Dedicated workload isolation
PreferNoSchedule
The scheduler avoids placing pods without a matching toleration, but places them if no other nodes are available.
Soft preference and non-critical separation
NoExecute
New pods without a matching toleration are not scheduled. Running pods without a matching toleration are evicted immediately, which means they are stopped and removed from the node. Use tolerationSeconds to delay eviction.
Maintenance, node draining to move all pods off a node, strict isolation
The following examples show a sample taint for each effect. Select the respective tab to view the scenario and the taint definition:
Reserve a node pool only for high-memory batch workloads. Pods without a matching workload=batch:NoSchedule toleration are not scheduled there. Managed Kubernetes system pods, such as CoreDNS, tolerate all NoSchedule and NoExecute taints and still run on these nodes. Existing pods on those nodes are not affected.
Soft-isolate a node pool for analytics jobs. Other pods avoid these nodes unless no other capacity is available. Analytics pods with a matching toleration can run there. To place them there, also add a nodeSelector.
Mark a node pool for scheduled maintenance. New pods are not scheduled, and running pods without a matching toleration are evicted. Pods with a tolerationSeconds value are given a grace period before eviction.
System taints
Kubernetes automatically applies the following taints based on node conditions. Manual action is not required.
Taint
Applied when
node.kubernetes.io/not-ready:NoExecute
The node is not in a Ready state.
node.kubernetes.io/unreachable:NoExecute
Kubernetes cannot reach the node.
node.kubernetes.io/memory-pressure:NoSchedule
The node is running low on available memory.
node.kubernetes.io/disk-pressure:NoSchedule
The node is running low on available disk space.
Kubernetes adds and removes these taints automatically when it detects a change in the node condition. Do not remove them manually.
Next steps
Last updated
Was this helpful?