Configure 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.
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.
For more information about taint components, taint effects and system taints, see Taints and tolerations.
Add a taint
A node without taints accepts any pod that the scheduler assigns to it. Adding a taint is the first step in controlling workload placement. The taint keeps pods without a matching toleration away from the node. You can add a taint at two levels:
Node pool level: The taint is part of the node pool specification and applies to all nodes in that pool. Use this level for lasting workload placement rules.
Individual node level: The taint applies only to a single node and is lost when the node is replaced. Use this level for temporary changes or testing.
After you add a taint, add a matching toleration to the workloads that must run on the tainted nodes. For more information, see Add tolerations to a workload.
Add a taint to a node pool
You can add taints to an IONOS CLOUD Managed Kubernetes node pool through the DCD, the IONOS CLOUD API, or Terraform. Taints set at the node pool level are applied to all nodes in that pool.
You can configure taints when creating or updating a node pool through the Advanced settings section in the Data Center Designer (DCD). For more information, see Configure Advanced settings.
Configure Advanced settings
Scroll to the Advanced settings section and go to Taints. For each taint, enter the following details and select Add:
Key: The taint identifier. Example:
workload.Value: An optional label. Example:
batch.Effect: Select
NoSchedule,PreferNoSchedule, orNoExecute.
Each added taint is listed in the key=value:Effect format. Example: workload=batch:NoSchedule. Repeat these steps for each taint you want to add.
Save changes
Select Edit node pool (or Create node pool for a new pool). The node pool state changes to Deploying while the changes are applied. When the node pool reaches the Available state, the taints apply to all nodes in the pool. Adding or removing node pool taints updates the existing nodes in place. The nodes are not replaced.
Find your cluster ID and node pool ID:
Add a taint to the node pool:
Replace
CLUSTER_ID,NODEPOOL_ID,YOUR_API_TOKEN, andNODE_COUNTwith your values.NODE_COUNTis the current number of nodes in the node pool. ThenodeCountproperty is required in every update request. To add more than one taint, include all taints in thetaintsarray.Verify the taints are applied to nodes in the pool:
You can configure taints on a node pool using the taints block in the ionoscloud_k8s_node_pool resource. Ensure that you have a Terraform provider v6.7.37 or later.
Each taints block defines one taint, up to the limit of 50 taints per node pool. Each block supports:
key: The taint key. Required. Follow the key format described in Understanding taints and tolerations.value: The taint value. Optional. Follow the value format described in Understanding taints and tolerations.effect: The taint effect. Required. Must be one ofNoSchedule,PreferNoSchedule, orNoExecute.
For the full resource reference, see ionoscloud_k8s_node_pool.
Apply a taint to an individual node
You can apply a taint directly to a single node using kubectl, which is ideal for temporary changes or testing.
List the nodes in your cluster:
Apply the taint:
For example, to mark a node as dedicated for batch workloads:
Verify the taint:
Output:
Add tolerations to a workload
To schedule a pod on a tainted node, add a tolerations block to the pod specification. The toleration must match the taint on the target node.
To apply the toleration and verify the pod placement, follow these steps:
Save the manifest to a file and apply it:
Check which nodes the pods run on:
The
NODEcolumn shows the node for each pod. Pods with a matching toleration can run on the tainted nodes.
Toleration operators
Operator
Behavior
value required?
Equal
The key and value must match the taint exactly.
Yes
Exists
Matches any taint with this key, whatever its value.
No
Tolerate a NoExecute taint with a grace period
If you add a NoExecute taint to a node, running pods without a matching toleration are evicted immediately. Add tolerationSeconds to delay eviction.
This pod is evicted 3,600 seconds (1 hour) after the taint is applied to the node.
Next steps
Last updated
Was this helpful?