tencent cloud

Tencent Kubernetes Engine

Setting a Node Label

Baixar
Modo Foco
Tamanho da Fonte
Última atualização: 2026-11-30 14:15:15
Traduzido e Verificado por IA

Operation Scenario

This document guides you through the process of setting a node Label.

Usage Restrictions

Labels related to kubernetes and qcloud cannot be edited or deleted.
kubernetes and qcloud labels are reserved keys and cannot be added.
System Labels on nodes are automatically added by Kubernetes and TKE components. They cannot be manually modified or deleted, and custom Labels cannot be added using these Keys or prefixes. For complete instructions, see Node System Labels below.
Currently, you can set Labels for one single node at a time, and batch setting is not supported.

Directions

Setting a Node Label in the Console
Setting a Node Label with kubectl
1. Log in to the TKE console and select Clusters in the left sidebar.
2. In the cluster list, click the target cluster ID to go to the cluster details page.
3. Choose Node Management. On the Nodes tab, choose More > Edit Label on the right side of the row for a regular node.
4. In Edit Label, set the Label as needed and click OK when done.
1. Install kubectl and connect to a cluster. For operation details, see Connecting to a Cluster via kubectl.
2. Run the following command to set a node Label.
kubectl label nodes <node-name> <label-key>=<label-value>
# node-name refers to the node IP address.
3. Run the following command to view the node Label.
kubectl get nodes --show-labels
A message similar to the one below is returned:
NAME STATUS ROLES AGE VERSION LABELS
172.17.124.5 Ready <none> 12d v1.10.5-tke.3 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/instance-type=QCLOUD,beta.kubernetes.io/os=linux,failure-domain.beta.kubernetes.io/region=sh,failure-domain.beta.kubernetes.io/zone=200002,kubernetes.io/hostname=172.17.124.5
172.17.124.8 Ready <none> 12d v1.10.5-tke.3 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/instance-type=QCLOUD,beta.kubernetes.io/os=linux,failure-domain.beta.kubernetes.io/region=sh,failure-domain.beta.kubernetes.io/zone=200002,kubernetes.io/hostname=172.17.124.8


Node System Label

When a node joins a cluster, Kubernetes and TKE components automatically add a set of system Labels to the Node object to identify the node identity, specifications, and topology information such as region and AZ. These Labels are maintained by the system. They cannot be modified or deleted through the console or node pool configurations, and custom Labels cannot be added using the same Keys or reserved prefixes.

Kubernetes Built-in Labels

Label Key
Description
Example Value
kubernetes.io/hostname
Node hostname, usually the private IP address of the node
10.0.1.22
kubernetes.io/os,kubernetes.io/arch
Operating system and CPU architecture
linux,amd64
node.kubernetes.io/instance-type
Instance type; eklet for super nodes
S2.MEDIUM2
beta.kubernetes.io/os,beta.kubernetes.io/arch,beta.kubernetes.io/instance-type
Legacy built-in labels, retained for compatibility with existing PVs and other objects
linux,amd64

Region and AZ-Related Labels

Note: AZ information on a node is written by different components, and the value formats of different labels vary: standard Kubernetes labels use numeric AZ IDs (for example, 100002), while CBS-CSI-specific labels use AZ names (for example, ap-guangzhou-2). Do not modify any of them, as this may cause inconsistent topology information read by different components.
Label Key
Description
Written By / Example Value
topology.kubernetes.io/zone
Kubernetes stable AZ Label
kubelet and cloud-provider; 100002
topology.kubernetes.io/region
Kubernetes stable region Label
gz
failure-domain.beta.kubernetes.io/zone
Legacy AZ Label, still read by existing objects such as PVs and CSIs.
100002
failure-domain.beta.kubernetes.io/region
Legacy region Label
gz
topology.com.tencent.cloud.csi.cbs/zone
CBS-CSI driver-specific topology Label for CBS AZ scheduling
CBS-CSI;ap-guangzhou-2
eks.tke.cloud.tencent.com/zone-name
Name of the AZ where the super node resides
eklet-agent;ap-singapore-1
In addition, super nodes record eks.tke.cloud.tencent.com/zone-id in Annotations. The spec.providerID of a node is in the format qcloud:///<AZ ID>/<instance ID>, which also contains AZ information. All this information is written by the system. Among them, spec.providerID is an immutable field of a Node and cannot be modified after creation.

TKE Business Labels

Label Key
Description
cloud.tencent.com/node-instance-id
ID of the CVM instance corresponding to the node
cloud.tencent.com/auto-scaling-group-id
ID of the scaling group to which the node belongs
cloud.tencent.com/provider
Cloud provider identifier, with a value of tencentcloud
tke.cloud.tencent.com/nodepool-id
ID of the node pool to which the node belongs
tke.cloud.tencent.com/cbs-mountable
Whether the instance type supports mounting CBS cloud disks.
tke.cloud.tencent.com/cdcid
ID of the Tencent Cloud CDC where the node resides
tke.cloud.tencent.com/location
Location information of the registered node
node.tke.cloud.tencent.com/*
Metadata of native nodes and machines, such as machine, machineset, instance-charge-type, cpu, memory, gpu, and accelerator-type
In addition to the exact Keys mentioned above, the following prefixes are also reserved by TKE and cannot be used for custom Labels: eks., tke., cloud.tencent.com, and node.tke.cloud.tencent.com.

About Cross-AZ Node Migration

Warning:
After a node is migrated across AZs, the AZ-related Labels are not automatically synchronized or updated, and TKE does not provide the capability to automatically rewrite these system Labels. Manually modifying individual Labels cannot ensure that components read consistent topology information, so do not rely on this method for remediation. To run workloads in another AZ, create a node pool or node in the target AZ, migrate the workloads, and then remove the original node.
Reason: A node's AZ information is not stored in a single location. Instead, it is distributed across multiple locations and is independently written and read by different components:
1. The Kubernetes standard AZ Labels and legacy compatibility Labels (topology.kubernetes.io/zone and failure-domain.beta.kubernetes.io/zone) are injected by kubelet and cloud-provider.
2. The topology Label dedicated to the CBS-CSI driver (topology.com.tencent.cloud.csi.cbs/zone) is written by the CSI component and used for CBS scheduling. Its value is an AZ name, which differs from the numeric AZ ID in item 1.
3. The eks.tke.cloud.tencent.com/zone-name Label and zone-id Annotation on a super node are written by eklet-agent.
4. The spec.providerID of a Node, in the format qcloud:///<AZ ID>/<instance ID>, is an immutable field of the Node and cannot be modified after creation.
Because this information is maintained by different components and the value formats are inconsistent, other components may add AZ-related Labels in the future, so the platform cannot reliably identify and rewrite all of them automatically. In particular, spec.providerID cannot be modified in place.
Impact: If the AZ of an instance changes but the above information is not synchronized, the topology information read by different components will be inconsistent. In this case, the CBS-CSI component will repeatedly restart (CrashLoopBackOff) due to a detected topology value collision, and CBS disks may fail to mount because they do not match the node's AZ, causing Pods to remain in Pending or abnormal states for a long time.
Troubleshooting suggestions: If the above symptoms occur, run kubectl get node <node-name> -o yaml to check whether the AZ Labels in labels, the annotations, and the spec.providerID are consistent with the instance's current actual AZ. Because this information cannot be reliably corrected in place, create a node in the target AZ to replace the original node. You can also refer to Avoiding cross-AZ CBS disk mounting with CBS-CSI to learn about the binding relationship between CBS disks and AZs.

Ajuda e Suporte

Esta página foi útil?

comentários