Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

Prerequisites: Before you begin, ensure you have the following:

  • An IONOS CLOUD Managed Kubernetes cluster. For more information, see Set Up a Kubernetes Cluster.

  • At least one node pool configured in your cluster. For more information, see Manage Node Pools.

  • kubectl installed and configured to access your cluster.

  • Depending on the method you use to configure node pool taints:

    • DCD: Access to the Data Center Designer (DCD).

    • IONOS CLOUD API: A valid API token, and ionosctl v6.9.9 or later installed to look up your cluster and node pool IDs.

    • Terraform: The ionoscloud Terraform provider v6.7.37 or later.

  • ionosctl v6.10.5 and later can set node pool taints: ionosctl compute k8s nodepool create takes --taints, and ionosctl compute k8s nodepool update takes --taints, --add-taints, and --remove-taints.

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.

1
  1. In the DCD, go to Menu > Containers > Managed Kubernetes.

  2. Select a cluster from the list and go to the Node pools in Cluster tab.

  3. Select the node pool you want to configure, or select Add node pool to create a new one.

2

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, or NoExecute.

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.

Note: You cannot edit an existing taint. To change a taint, remove it and add a new one with the updated key, value, or effect. For more information, see Remove a taint from a node pool.

3

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.

  1. Find your cluster ID and node pool ID:

  2. Add a taint to the node pool:

    Replace CLUSTER_ID, NODEPOOL_ID, YOUR_API_TOKEN, and NODE_COUNT with your values. NODE_COUNT is the current number of nodes in the node pool. The nodeCount property is required in every update request. To add more than one taint, include all taints in the taints array.

    Note: Within a node pool, each taint must have a unique combination of key and effect. The API rejects duplicate key-effect pairs, even with different values, with HTTP 422 and error code 631.

  3. 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:

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.

Note: Taints that you add to a node with kubectl stay when IONOS CLOUD Managed Kubernetes applies the node pool settings again, for example after a node pool update. A node taint with the same key and effect as a node pool taint is then set back to the node pool value. If you change or remove a node pool taint with kubectl, the change lasts until the node pool settings are applied again. Taints added with kubectl are lost when the node is replaced.

  1. List the nodes in your cluster:

  2. Apply the taint:

    For example, to mark a node as dedicated for batch workloads:

  3. 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:

  1. Save the manifest to a file and apply it:

  2. Check which nodes the pods run on:

    The NODE column shows the node for each pod. Pods with a matching toleration can run on the tainted nodes.

Note: A toleration allows a pod to run on a tainted node but does not force it there. To keep a workload on a specific node pool, also add a nodeSelector that matches the node pool labels.

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?