Use cluster labels in AKS enabled by Azure Arc
Applies to: Azure Stack HCI, version 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
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
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"
Unavailable labels
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.
Next steps
For more information about Kubernetes labels, see the Kubernetes documentation.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for