Edit

Share via


Delete an Azure Kubernetes Service (AKS) cluster

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

What happens when you delete a cluster?

When you delete a cluster, the following resources are deleted:

  • The node resource group and its resources, including:
    • The virtual machine scale sets and virtual machines (VMs) for each node in the cluster
    • The virtual network and its subnets for the cluster
    • The storage for the cluster
  • The control plane and its resources
  • Any node instances in the cluster along with any pods running on those nodes

Alternatives to deleting a cluster

Before you delete a cluster, consider stopping the cluster. Stopping an AKS cluster stops the control plane and agent nodes, allowing you to save on compute costs while maintaining all objects except standalone pods. When you stop a cluster, its state is saved and you can restart the cluster at any time. For more information, see Stop an AKS cluster.

If you want to delete a cluster to change its configuration, you can instead use the AKS cluster upgrade feature to upgrade the cluster to a different Kubernetes version or change the node pool configuration. For more information, see Upgrade an AKS cluster.

Delete a cluster

Important

You can't recover a cluster after it's deleted. If you need to recover a cluster, you need to create a new cluster and redeploy your applications.

Delete a cluster using the az aks delete command. The following example deletes the myAKSCluster cluster in the myResourceGroup resource group.

Declare environment variables with generic names and a random suffix to ensure uniqueness. This avoids conflicts and enables the commands to be re-used in different sessions or by different users.

export RANDOM_SUFFIX=$(openssl rand -hex 3)
export AKS_CLUSTER_NAME="myAKSCluster$RANDOM_SUFFIX"
export RESOURCE_GROUP_NAME="myResourceGroup$RANDOM_SUFFIX"
az aks delete --name $AKS_CLUSTER_NAME --resource-group $RESOURCE_GROUP_NAME --yes --no-wait

Next steps

For more information about AKS, see Core Kubernetes concepts for AKS.