Muokkaa

Jaa


Delete an Azure Kubernetes Service (AKS) node pool

This article outlines node pool deletion in Azure Kubernetes Service (AKS), including what happens when you delete a node pool and how to delete a node pool.

What happens when you delete a node pool?

When you delete a node pool, the following resources are deleted:

  • The virtual machine scale set (VMSS) and virtual machines (VMs) for each node in the node pool
  • Any node instances in the node pool along with any pods running on those nodes

Delete a node pool

Important

Keep the following information in mind when deleting a node pool:

  • You can't recover a node pool after it's deleted. You need to create a new node pool and redeploy your applications.

Delete a node pool using the az aks nodepool delete command.

az aks nodepool delete \
    --resource-group <resource-group-name> \
    --cluster-name <cluster-name> \
    --name <node-pool-name>

To verify that the node pool was deleted successfully, use the kubectl get nodes command to confirm that the nodes in the node pool no longer exist.

Ignore PodDisruptionBudgets (PDBs) when removing an existing node pool

If your cluster has PodDisruptionBudgets that are preventing the deletion of the node pool, you can ignore the PodDisruptionBudget requirements by setting --ignore-pod-disruption-budget to true. To learn more about PodDisruptionBudgets, see:

  1. Delete an existing node pool without following any PodDisruptionBudgets set on the cluster using the az aks nodepool delete command with the --ignore-pod-disruption-budget flag set to true:

    az aks nodepool delete \
        --resource-group myResourceGroup \
        --cluster-name myAKSCluster \
        --name nodepool1
        --ignore-pod-disruption-budget true
    
  2. To verify that the node pool was deleted successfully, use the kubectl get nodes command to confirm that the nodes in the node pool no longer exist.

Remove specific VMs in an existing node pool

Note

When you delete a VM with this command, AKS doesn't perform cordon and drain. To minimize the disruption of rescheduling pods currently running on the VM you plan to delete, perform a cordon and drain on the VM before deleting. You can learn more about how to cordon and drain using the example scenario provided in the resizing node pools tutorial.

  1. List the existing nodes using the kubectl get nodes command.

    kubectl get nodes
    

    Your output should look similar to the following example output:

    NAME                                 STATUS   ROLES   AGE   VERSION
    aks-mynodepool-20823458-vmss000000   Ready    agent   63m   v1.21.9
    aks-mynodepool-20823458-vmss000001   Ready    agent   63m   v1.21.9
    aks-mynodepool-20823458-vmss000002   Ready    agent   63m   v1.21.9
    
  2. Delete the specified VMs using the az aks nodepool delete-machines command. Make sure to replace the placeholders with your own values.

    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>
    
  3. Verify the VMs were successfully deleted using the kubectl get nodes command.

    kubectl get nodes
    

    Your output should no longer include the VMs that you specified in the az aks nodepool delete-machines command.

Next steps

For more information about adjusting node pool sizes in AKS, see Resize node pools.