Manage node labels and taints

更新时间:
复制 MD 格式

Node labels and taints give you precise control over how Kubernetes schedules pods across your cluster. Labels classify nodes and act as selectors for workload placement. Taints repel pods from nodes — only pods with a matching toleration can be scheduled to a tainted node.

A common use case: GPU nodes are expensive. Add a taint to reserve them exclusively for GPU workloads, so general-purpose pods are never scheduled there by default.

For background on labels and taints, see Labels and selectors and Taints and tolerations in the Kubernetes documentation.

Taint effects

Each taint has an effect that determines how Kubernetes handles pods that lack a matching toleration.

EffectBehavior
NoScheduleThe system does not schedule pods to the node.
NoExecuteThe system does not schedule pods to the node, and pods that do not have matching tolerations are evicted from the node.
PreferNoScheduleThe system attempts to avoid scheduling pods that do not have matching tolerations to the node. This effect does not specify a hard requirement.

Add and manage node labels

Labels identify and classify nodes, and serve as selectors when scheduling workloads to specific nodes.

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, choose Nodes > Nodes.

  3. Click Manage Labels and Taints. On the Labels tab, select the target nodes and click Add Label. In the Add dialog box, set Name and Value, then confirm.

After the label is added, it appears in the Labels column for the node. From that column, you can:

  • Click a label to filter nodes by that label.

  • Click the 5.jpg icon next to a label to delete it.

Note

Specific Kubernetes-native labels cannot be deleted. If you delete such a label, the system automatically re-adds it to the node.

Add and manage node taints

Use taints to restrict which pods can run on a node. Typical scenarios:

  • Dedicated nodes: Reserve a group of nodes for specific users or workloads.

  • Hardware specialization: Ensure only pods that require GPU resources are scheduled to GPU nodes.

  • Pod eviction: Add a NoExecute taint to evict all pods from a node. To retain a specific pod, add a matching NoExecute toleration to that pod.

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, choose Nodes > Nodes.

  3. Click Manage Labels and Taints. On the Taints tab, select the target nodes and click Add Taint. In the Add dialog box, set Name, Value, and Effect, then confirm.

    ParameterConstraints
    Name1–63 characters. Allowed characters: letters, digits, hyphens (-), underscores (_), and periods (.). Must start and end with a letter or digit. To use a prefixed key, the prefix must be a DNS subdomain name (DNS labels separated by periods, up to 253 characters), followed by a forward slash (/).
    ValueOptional. Up to 63 characters. Allowed characters: letters, digits, hyphens (-), underscores (_), and periods (.). Must start and end with a letter or digit if not blank.
    EffectOne of NoSchedule, NoExecute, or PreferNoSchedule. See Taint effects.

After the taint is added, it appears in the Taints column for the node. From that column, you can:

  • Click a taint to filter nodes by that taint.

  • Click the 5.jpg icon next to a taint to delete it.

What's next