Managing your AKS clusters efficiently is crucial, especially when dealing with problematic nodes or reducing the number of deallocated nodes. With the AKS node deletion feature in preview, you can now remove specific VMs without switching the node pool state.
Steps to Remove Specific VMs in AKS
First you need to ensure you have the latest aks-preview extension:
1 2 |
az extension add --name aks-preview az extension update --name aks-preview |
Now let’s see what nodes you have running:
1 |
kubectl get nodes |
Pick one of the nodes you would like to delete and then use the following command to remove it. Just make sure you pick the right node.
1 2 3 4 5 |
az aks nodepool delete-machines \ --resource-group <resource-group-name> \ --cluster-name <cluster-name> \ --name <node-pool-name> \ --machine-names <vm-name-1> <vm-name-2> |
Did you notice in the command you can even do more than one VM at a time? It’s just a space separated list.
Now just run kubectl get nodes
again and you should see your nodes are either being removed or removed already.
Conclusion
Deleting specific nodes directly from a node pool simplifies cluster management, making it easier to handle deallocated nodes or problematic VMs. This feature, now in preview, enhances your ability to maintain optimal performance and resource allocation in AKS.
0 Comments