Skip to content

Commit 06ea648

Browse files
author
Jill Grant
authored
Merge pull request #274926 from schaffererin/userstory250988
AKS new content for deleting specific machines and ignoring PDBs on delete
2 parents 9b22db7 + bd994c9 commit 06ea648

File tree

3 files changed

+168
-8
lines changed

3 files changed

+168
-8
lines changed

articles/aks/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@
300300
href: use-system-pools.md
301301
- name: Resize node pools
302302
href: resize-node-pool.md
303+
- name: Delete node pools
304+
href: delete-node-pool.md
303305
- name: Virtual nodes
304306
items:
305307
- name: Use virtual nodes

articles/aks/delete-node-pool.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
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].
97+
98+
<!-- LINKS -->
99+
[az-aks-delete-nodepool]: /cli/azure/aks#az_aks_nodepool_delete
100+
[remove-azaksnodepool]: /powershell/module/az.aks/remove-azaksnodepool
101+
[resize-node-pool]: ./resize-node-pool.md
102+
[pod-disruption-budget]: operator-best-practices-scheduler.md#plan-for-availability-using-pod-disruption-budgets
103+
[specify-disruption-budget]: https://kubernetes.io/docs/tasks/run-application/configure-pdb/
104+
[disruptions]: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/
105+
[az-extension-add]: /cli/azure/extension#az-extension-add
106+
[az-extension-update]: /cli/azure/extension#az-extension-update

articles/aks/manage-node-pools.md

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ms.custom: devx-track-azurecli, build-2023
66
ms.date: 07/19/2023
77
author: schaffererin
88
ms.author: schaffererin
9-
109
ms.subservice: aks-nodes
1110
---
1211

@@ -187,15 +186,64 @@ AKS offers a separate feature to automatically scale node pools with a feature c
187186
188187
For more information, see [use the cluster autoscaler](cluster-autoscaler.md#use-the-cluster-autoscaler-on-multiple-node-pools).
189188
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:
212+
213+
```output
214+
NAME STATUS ROLES AGE VERSION
215+
aks-mynodepool-20823458-vmss000000 Ready agent 63m v1.21.9
216+
aks-mynodepool-20823458-vmss000001 Ready agent 63m v1.21.9
217+
aks-mynodepool-20823458-vmss000002 Ready agent 63m v1.21.9
218+
```
219+
220+
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
191239
192240
As your workload demands change, you can associate existing capacity reservation groups to node pools to guarantee allocated capacity for your node pools.
193241
194242
## Prerequisites to use capacity reservation groups with AKS
195243
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.
199247
200248
```azurecli-interactive
201249
IDENTITY_NAME=myID
@@ -207,14 +255,17 @@ As your workload demands change, you can associate existing capacity reservation
207255
az identity create --name $IDENTITY_NAME --resource-group $RG_NAME
208256
IDENTITY_ID=$(az identity show --name $IDENTITY_NAME --resource-group $RG_NAME --query identity.id -o tsv)
209257
```
210-
- 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+
212262
```azurecli-interactive
213263
az aks create --resource-group $RG_NAME --name $CLUSTER_NAME --location $LOCATION \
214264
--node-vm-size $VM_SKU --node-count $NODE_COUNT \
215265
--assign-identity $IDENTITY_ID --enable-managed-identity
216266
```
217-
- You can also assign the user-managed identity on an existing managed cluster with update command.
267+
268+
* You can also assign the user-managed identity on an existing managed cluster with update command.
218269

219270
```azurecli-interactive
220271
az aks update --resource-group $RG_NAME --name $CLUSTER_NAME --location $LOCATION \
@@ -541,3 +592,4 @@ When you use an Azure Resource Manager template to create and manage resources,
541592
[az-extension-add]: /cli/azure/extension#az_extension_add
542593
[az-extension-update]: /cli/azure/extension#az_extension_update
543594
[use-node-taints]: ./use-node-taints.md
595+
[az-aks-nodepool-delete-machines]: /cli/azure/aks/nodepool#az_aks_nodepool_delete_machines

0 commit comments

Comments
 (0)