title | description | ms.topic | ms.date | author | ms.author | ms.lastreviewed | ms.reviewer |
---|---|---|---|---|---|---|---|
Use cluster labels in AKS enabled by Azure Arc |
Learn how to use labels in Kubernetes clusters in AKS enabled by Arc. |
how-to |
01/18/2024 |
sethmanheim |
sethm |
01/18/2024 |
guanghu |
[!INCLUDE hci-applies-to-23h2]
If you have multiple node pools, you might want to add a label during node pool creation. Kubernetes labels handle the scheduling rules for nodes.
This article describes how to use labels in a Kubernetes cluster on AKS enabled by Arc.
-
Create a Kubernetes cluster with a label using the
az aksarc create
command and specify the--node-labels
parameter to set your labels. Labels must be a key/value pair and have valid syntax.az aksarc create --resource-group myResourceGroup --name myAKSCluster --node-count 2 --nodepool-labels dept=IT
-
Verify that the labels were set using the
kubectl get nodes --show-labels
command:kubectl get nodes --show-labels | grep -e "dept=IT"
-
Create a node pool with a label using the
az aksarc nodepool add
command and specify a name for the--name
parameters and labels for the--labels
parameter. Labels must be a key/value pair and have valid syntax.The following example creates a node pool named
labelnp
with the labelsdept=HR
:az aks nodepool add –resource-group myResourceGroup –cluster-name myAKSCluster –name labelnp –node-count 1 –labels dept=HR –no-wait
The following example output from the
az aksarc nodepool list
command shows thelabelnp
node pool creates nodes with the specifiednodeLabels
:[ { ... "count": 1, ... "name": "labelnp", "orchestratorVersion": "1.15.7", ... "provisioningState": "Creating", ... "nodeLabels": { "costcenter": "5000", "dept": "HR" }, ... }, ... ]
-
Verify the labels were set using the
kubectl get nodes --show-labels
command:kubectl get nodes --show-labels | grep -e "dept=HR"
AKS enabled by Azure Arc follows the same rules as AKS:
- You can't change the reserved system label. If you attempt to do so, an error is returned.
- The Kubernetes and AKS reserved prefixes can't be used for any node.
For more information, see Unavailable labels in the AKS documentation.
For more information about Kubernetes labels, see the Kubernetes documentation.