Skip to content

Commit 730b8de

Browse files
committed
initial commit
1 parent 2137049 commit 730b8de

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

articles/aks/use-multiple-node-pools.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ The valid Kubernetes upgrades for a cluster's control plane and node pools are v
241241
* If a node pool Kubernetes version is not specified, behavior depends on the client being used. Declaration in Resource Manager templates falls back to the existing version defined for the node pool if used, if none is set the control plane version is used to fall back on.
242242
* You can either upgrade or scale a control plane or a node pool at a given time, you cannot submit multiple operations on a single control plane or node pool resource simultaneously.
243243

244+
244245
## Scale a node pool manually
245246

246247
As your application workload demands change, you may need to scale the number of nodes in a node pool. The number of nodes can be scaled up or down.
@@ -299,6 +300,99 @@ It takes a few minutes for the scale operation to complete.
299300

300301
AKS offers a separate feature to automatically scale node pools with a feature called the [cluster autoscaler](cluster-autoscaler.md). This feature can be enabled per node pool with unique minimum and maximum scale counts per node pool. Learn how to [use the cluster autoscaler per node pool](cluster-autoscaler.md#use-the-cluster-autoscaler-with-multiple-node-pools-enabled).
301302

303+
## Resize a node pool
304+
305+
To increase of number of deployments or run a larger workload, you may want to change the VMSS plan or resize AKS instances. However, you should not do any direct customizations to these nodes using the IaaS APIs or resources, as any custom changes that are not done via the AKS API will not persist through an upgrade, scale, update or reboot. This means resizing your AKS instances in this manner is not supported.
306+
307+
The recommended method to resize a node pool to the desired SKU size is as follows:
308+
309+
* Create a new node pool with the new SKU size
310+
* Cordon and drain the nodes in the old node pool in order to move workloads to the new nodes
311+
* Remove the old node pool.
312+
313+
> [!IMPORTANT]
314+
> This method is specific to VMSS-based AKS clusters. When using VMAS, you are limited to only one node pool per cluster.
315+
316+
### Create a new node pool with the desired SKU
317+
318+
The following command creates a new node pool with 2 nodes using the `Standard_DS3_v2` VM SKU:
319+
320+
> [!NOTE]
321+
> Every AKS cluster must contain at least one system node pool with at least one node. In the below example, we are using a `--mode` of `System`, as the cluster is assumed to have only one node pool, necessitating a `System` node pool to replace it. A node pool's mode can be [updated at any time][update-node-pool-mode].
322+
323+
```azurecli-interactive
324+
az aks nodepool add \
325+
--resource-group myResourceGroup \
326+
--cluster-name myAKSCluster \
327+
--name mynodepool \
328+
--node-count 2 \
329+
--node-vm-size Standard_DS3_v2 \
330+
--mode System \
331+
--no-wait
332+
```
333+
334+
Be sure to consider other requirements and configure your node pool accordingly. You may need to modify the above command. For a full list of the configuration options, please see the [az aks nodepool add][az-aks-nodepool-add] reference page.
335+
336+
### Cordon the existing nodes
337+
338+
Cordoning marks specified nodes as unschedulable and prevents any additional pods from being added to the nodes.
339+
340+
First, obtain the names of the nodes you'd like to cordon with `kubectl get nodes`. Your output should look similar to the following:
341+
342+
```bash
343+
NAME STATUS ROLES AGE VERSION
344+
aks-nodepool1-31721111-vmss000000 Ready agent 7d21h v1.21.9
345+
aks-nodepool1-31721111-vmss000001 Ready agent 7d21h v1.21.9
346+
aks-nodepool1-31721111-vmss000002 Ready agent 7d21h v1.21.9
347+
```
348+
349+
Next, using `kubectl cordon <node-names>`, specify the desired nodes in a space-separated list:
350+
351+
```bash
352+
kubectl cordon aks-nodepool1-31721111-vmss000000 aks-nodepool1-31721111-vmss000001 aks-nodepool1-31721111-vmss000002
353+
```
354+
355+
If succesful, your output should look similar to the following:
356+
357+
```bash
358+
node/aks-nodepool1-31721111-vmss000000 cordoned
359+
node/aks-nodepool1-31721111-vmss000001 cordoned
360+
node/aks-nodepool1-31721111-vmss000002 cordoned
361+
```
362+
363+
### Drain the existing nodes
364+
365+
> [!IMPORTANT]
366+
> To successfully drain nodes and evict running pods, ensure that any PodDisruptionBudgets (PDBs) allow for at least 1 pod replica to be moved at a time, otherwise the drain/evict operation will fail. To check this, you can run `kubectl get pdb -A` and make sure `ALLOWED DISRUPTIONS` is at least 1 or higher.
367+
368+
Draining nodes will cause pods running on them to be evicted and recreated on the other, schedulable nodes.
369+
370+
To drain nodes, use `kubectl drain <node-names> --ignore-daemonsets --delete-emptydir-data`, again using a space-separated list of node names:
371+
372+
> [!IMPORTANT]
373+
> Using `--delete-emptydir-data` is required to evict the AKS-created `coredns` and `metrics-server` pods. If this flag isn't used, an error is expected. Please see the [documentation on emptydir][empty-dir] for more information.
374+
375+
```bash
376+
kubectl drain aks-nodepool1-31721111-vmss000000 aks-nodepool1-31721111-vmss000001 aks-nodepool1-31721111-vmss000002 --ignore-daemonsets --delete-emptydir-data
377+
```
378+
379+
> [!TIP]
380+
> By default, your cluster has AKS_managed pod disruption budgets (such as `coredns-pdb` or `konnectivity-agent`) with a `MinAvailable` of 1. If, for example, there are two `coredns` pods running, while one of them is getting recreated and is unavailable, the other is unable to be affected due to the pod disruption budget. This resolves itself after the initial `coredns` pod is scheduled and running, allowing the second pod to be properly evicted and recreated.
381+
>
382+
> Consider draining nodes one-by-one for a smoother eviction experience and to avoid throttling. For more information, see [plan for availability using a pod disruption budget][pod-disruption-budget].
383+
384+
After the drain operation finishes, verify pods are running on the new nodepool:
385+
386+
```bash
387+
kubectl get pods -o wide -A
388+
```
389+
390+
### Remove the existing node pool
391+
392+
To delete the existing node pool, see [the below steps](#delete-a-node-pool)
393+
394+
After completion, the final result is the AKS cluster having a single, new node pool with the new, desired SKU size and all the applications and pods properly running.
395+
302396
## Delete a node pool
303397

304398
If you no longer need a pool, you can delete it and remove the underlying VM nodes. To delete a node pool, use the [az aks node pool delete][az-aks-nodepool-delete] command and specify the node pool name. The following example deletes the *mynoodepool* created in the previous steps:
@@ -875,6 +969,7 @@ Use [proximity placement groups][reduce-latency-ppg] to reduce latency for your
875969
[kubernetes-labels]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
876970
[kubernetes-label-syntax]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
877971
[capacity-reservation-groups]:/azure/virtual-machines/capacity-reservation-associate-virtual-machine-scale-set
972+
[empty-dir]: https://kubernetes.io/docs/concepts/storage/volumes/#emptydir
878973

879974
<!-- INTERNAL LINKS -->
880975
[aks-windows]: windows-container-cli.md
@@ -916,3 +1011,5 @@ Use [proximity placement groups][reduce-latency-ppg] to reduce latency for your
9161011
[node-image-upgrade]: node-image-upgrade.md
9171012
[fips]: /azure/compliance/offerings/offering-fips-140-2
9181013
[use-tags]: use-tags.md
1014+
[update-node-pool-mode]: use-system-pools.md#update-existing-cluster-system-and-user-node-pools
1015+
[pod-disruption-budget]: operator-best-practices-scheduler.md#plan-for-availability-using-pod-disruption-budgets

0 commit comments

Comments
 (0)