You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Delete an Azure Kubernetes Service (AKS) node pool
3
+
description: Learn about deleting a node pool from your Azure Kubernetes Service (AKS) cluster.
4
+
ms.topic: overview
5
+
ms.author: alvinli
6
+
author: alvinli
7
+
ms.date: 05/09/2024
8
+
---
9
+
10
+
# Delete an Azure Kubernetes Service (AKS) node pool
11
+
12
+
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.
13
+
14
+
## What happens when you delete a node pool?
15
+
16
+
When you delete a node pool, the following resources are deleted:
17
+
18
+
* The virtual machine scale set (VMSS) and virtual machines (VMs) for each node in the node pool
19
+
* Any node instances in the node pool along with any pods running on those nodes
20
+
21
+
## Delete a node pool
22
+
23
+
> [!IMPORTANT]
24
+
> Keep the following information in mind when deleting a node pool:
25
+
>
26
+
> ***You can't recover a node pool after it's deleted**. You need to create a new node pool and redeploy your applications.
27
+
> * When you delete a node pool, AKS doesn't perform cordon and drain. To minimize the disruption of rescheduling pods currently running on the node pool you plan to delete, perform a cordon and drain on all nodes in the node pool before deleting. You can learn more about how to cordon and drain using the example scenario provided in the [resizing node pools][resize-node-pool] tutorial.
28
+
29
+
### [Azure CLI](#tab/azure-cli)
30
+
31
+
Delete a node pool using the [`az aks nodepool delete`][az-aks-delete-nodepool] command.
32
+
33
+
```azurecli-interactive
34
+
az aks nodepool delete \
35
+
--resource-group <resource-group-name> \
36
+
--cluster-name <cluster-name> \
37
+
--name <node-pool-name>
38
+
```
39
+
40
+
### [Azure PowerShell](#tab/azure-powershell)
41
+
42
+
Delete a node pool using the [`Remove-AzAksNodePool`][remove-azaksnodepool] cmdlet.
43
+
44
+
```azurepowershell-interactive
45
+
$params = @{
46
+
ResourceGroupName = '<resource-group-name>'
47
+
ClusterName = '<cluster-name>'
48
+
Name = '<node-pool-name>'
49
+
Force = $true
50
+
}
51
+
Remove-AzAksNodePool @params
52
+
```
53
+
54
+
### [Azure portal](#tab/azure-portal)
55
+
56
+
To delete a node pool in Azure portal, navigate to the **Settings > Node pools** page for the cluster and select the name of the node pool you want to delete. On the **Node Pool | Overview** page, you can select **Delete** to delete the node pool.
57
+
58
+
---
59
+
60
+
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.
61
+
62
+
## Ignore PodDisruptionBudgets (PDBs) when removing an existing node pool (Preview)
63
+
64
+
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:
65
+
66
+
*[Plan for availability using a pod disruption budget][pod-disruption-budget]
67
+
*[Specifying a Disruption Budget for your Application][specify-disruption-budget]
68
+
*[Disruptions][disruptions]
69
+
70
+
[!INCLUDE [preview features callout](includes/preview/preview-callout.md)]
71
+
72
+
1. Register or update the `aks-preview` extension using the [`az extension add`][az-extension-add] or [`az extension update`][az-extension-update] command.
73
+
74
+
```azurecli-interactive
75
+
# Register the aks-preview extension
76
+
az extension add --name aks-preview
77
+
78
+
# Update the aks-preview extension
79
+
az extension update --name aks-preview
80
+
```
81
+
82
+
2. Delete an existing node pool without following any PodDisruptionBudgets set on the cluster using the [`az aks nodepool delete`][az-aks-delete-nodepool] command with the `--ignore-pod-disruption-budget` flag set to `true`:
83
+
84
+
```azurecli-interactive
85
+
az aks nodepool delete \
86
+
--resource-group myResourceGroup \
87
+
--cluster-name myAKSCluster \
88
+
--name nodepool1
89
+
--ignore-pod-disruption-budget true
90
+
```
91
+
92
+
3. 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.
93
+
94
+
## Next steps
95
+
96
+
For more information about adjusting node pool sizes in AKS, see [Resize node pools][resize-node-pool].
@@ -187,15 +186,64 @@ AKS offers a separate feature to automatically scale node pools with a feature c
187
186
188
187
For more information, see [use the cluster autoscaler](cluster-autoscaler.md#use-the-cluster-autoscaler-on-multiple-node-pools).
189
188
190
-
## Associate capacity reservation groups to node pools
189
+
## Remove specific VMs in the existing node pool (Preview)
190
+
191
+
[!INCLUDE [preview features callout](includes/preview/preview-callout.md)]
192
+
193
+
### [Azure CLI](#tab/azure-cli)
194
+
195
+
1. Register or update the `aks-preview` extension using the [`az extension add`][az-extension-add] or [`az extension update`][az-extension-update] command.
196
+
197
+
```azurecli-interactive
198
+
# Register the aks-preview extension
199
+
az extension add --name aks-preview
200
+
201
+
# Update the aks-preview extension
202
+
az extension update --name aks-preview
203
+
```
204
+
205
+
2. List the existing nodes using the `kubectl get nodes` command.
206
+
207
+
```bash
208
+
kubectl get nodes
209
+
```
210
+
211
+
Your output should look similar to the following example output:
3. Delete the specified VMs using the [`az aks nodepool delete-machines`][az-aks-nodepool-delete-machines] command. Make sure to replace the placeholders with your own values.
221
+
222
+
```azurecli-interactive
223
+
az aks nodepool delete-machines \
224
+
--resource-group <resource-group-name> \
225
+
--cluster-name <cluster-name> \
226
+
--name <node-pool-name>
227
+
--machine-names <vm-name-1> <vm-name-2>
228
+
```
229
+
230
+
4. Verify the VMs were successfully deleted using the `kubectl get nodes` command.
231
+
232
+
```bash
233
+
kubectl get nodes
234
+
```
235
+
236
+
Your output should no longer include the VMs that you specified in the `az aks nodepool delete-machines` command.
237
+
238
+
## Associate capacity reservation groups to node pools
191
239
192
240
As your workload demands change, you can associate existing capacity reservation groups to node pools to guarantee allocated capacity for your node pools.
193
241
194
242
## Prerequisites to use capacity reservation groups with AKS
195
243
196
-
- Use CLI version 2.56 or above and API version 2023-10-01 or higher.
197
-
- The capacity reservation group should already exist and should contain minimum one capacity reservation, otherwise the node pool is added to the cluster with a warning and no capacity reservation group gets associated. For more information, see [capacity reservation groups][capacity-reservation-groups].
198
-
- You need to create a user-assigned managed identity for the resource group that contains the capacity reservation group (CRG). System-assigned managed identities won't work for this feature. In the following example, replace the environment variables with your own values.
244
+
* Use CLI version 2.56 or above and API version 2023-10-01 or higher.
245
+
* The capacity reservation group should already exist and should contain minimum one capacity reservation, otherwise the node pool is added to the cluster with a warning and no capacity reservation group gets associated. For more information, see [capacity reservation groups][capacity-reservation-groups].
246
+
* You need to create a user-assigned managed identity for the resource group that contains the capacity reservation group (CRG). System-assigned managed identities won't work for this feature. In the following example, replace the environment variables with your own values.
199
247
200
248
```azurecli-interactive
201
249
IDENTITY_NAME=myID
@@ -207,14 +255,17 @@ As your workload demands change, you can associate existing capacity reservation
207
255
az identity create --name $IDENTITY_NAME --resource-group $RG_NAME
- You need to assign the `Contributor` role to the user-assigned identity created above. For more details, see [Steps to assign an Azure role](/azure/role-based-access-control/role-assignments-steps#privileged-administrator-roles).
211
-
- Create a new cluster and assign the newly created identity.
258
+
259
+
* You need to assign the `Contributor` role to the user-assigned identity created above. For more details, see [Steps to assign an Azure role](/azure/role-based-access-control/role-assignments-steps#privileged-administrator-roles).
260
+
* Create a new cluster and assign the newly created identity.
261
+
212
262
```azurecli-interactive
213
263
az aks create --resource-group $RG_NAME --name $CLUSTER_NAME --location $LOCATION \
0 commit comments