|
| 1 | +--- |
| 2 | +title: Use Generation 2 virtual machines in Azure Kubernetes Service (AKS) |
| 3 | +description: Learn how to use Generation 2 virtual machines on Windows and Linux node pools in Azure Kubernetes Service (AKS). |
| 4 | +ms.topic: article |
| 5 | +ms.custom: azure-kubernetes-service |
| 6 | +ms.date: 05/03/2024 |
| 7 | +ms.author: schaffererin |
| 8 | +author: schaffererin |
| 9 | +--- |
| 10 | + |
| 11 | +# Use generation 2 virtual machines in Azure Kubernetes Service (AKS) |
| 12 | + |
| 13 | +Azure supports [Generation 2 (Gen 2) virtual machines (VMs)](../virtual-machines/generation-2.md). Generation 2 VMs support key features not supported in Generation 1 (Gen 1) VMs, including increased memory, Intel Software Guard Extensions (Intel SGX), and virtualized persistent memory (vPMEM). |
| 14 | + |
| 15 | +Generation 2 VMs use the new UEFI-based boot architecture rather than the BIOS-based architecture used by Generation 1 VMs. Only specific SKUs and sizes support Generation 2 VMs. Check the [list of supported sizes](../virtual-machines/generation-2.md#generation-2-vm-sizes) to see if your SKU supports or requires Generation 2. |
| 16 | + |
| 17 | +Additionally, not all VM images support Generation 2 VMs. On AKS, Generation 2 VMs use the AKS Ubuntu 22.04 or 18.04 image or the AKS Windows Server 2022 image. These images support all Generation 2 SKUs and sizes. |
| 18 | + |
| 19 | +## Default behavior for supported vm sizes |
| 20 | + |
| 21 | +There are three scenarios when creating a node pool with a supported VM size: |
| 22 | + |
| 23 | +1. If the VM size supports only Generation 1, the default behavior for both Linux and Windows node pools is to use the Generation 1 node image. |
| 24 | +2. If the VM size supports only Generation 2, the default behavior for both Linux and Windows node pools is to use the Generation 2 node image. |
| 25 | +3. If the VM size supports both Generation 1 and Generation 2, the default behavior for Linux and Windows differs. Linux uses the Generation 2 node image, and Windows uses Generation 1 image. To use the Generation 2 node image, see [Create a Windows node pool with a Generation 2 VM](#create-a-node-pool-with-a-generation-2-vm). |
| 26 | + |
| 27 | +## Check available Generation 2 VM sizes |
| 28 | + |
| 29 | +Check available Generation 2 VM sizes using the [`az vm list-skus`][az-vm-list-skus] command. |
| 30 | + |
| 31 | +```azurecli-interactive |
| 32 | +az vm list-skus --location <location> --size <vm-size> --output table |
| 33 | +``` |
| 34 | + |
| 35 | +## Create a node pool with a Generation 2 VM |
| 36 | + |
| 37 | +### [Linux node pool](#tab/linux-node-pool) |
| 38 | + |
| 39 | +By default, Linux uses the Generation 2 node image unless the VM size doesn't support Generation 2. |
| 40 | + |
| 41 | +Create a Linux node pool with a Generation 2 VM using the default [node pool creation][create-node-pools] process. |
| 42 | + |
| 43 | +### [Windows node pool](#tab/windows-node-pool) |
| 44 | + |
| 45 | +By default, Windows uses the Generation 1 node image unless the VM size doesn't support Generation 1. |
| 46 | + |
| 47 | +Create a Windows node pool with a Generation 2 VM using the [`az aks nodepool add`][az-aks-nodepool-add] command. To specify that you want to use Generation 2, add a custom header `--aks-custom-headers UseWindowsGen2VM=true`. Generation 2 VM also requires Windows Server 2022. |
| 48 | + |
| 49 | +```azurecli-interactive |
| 50 | +az aks nodepool add --resource-group <resource-group-name> --cluster-name <cluster-name> --name <node-pool-name> --vm-size <supported-generation-2-vm-size> --os-type Windows --os-sku Windows2022 --aks-custom-headers UseWindowsGen2VM=true |
| 51 | +``` |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## Update an existing node pool to use a Generation 2 VM |
| 56 | + |
| 57 | +### [Linux node pool](#tab/linux-node-pool) |
| 58 | + |
| 59 | +If you're using a VM size that only supports Generation 1, you can update your node pool to a vm size that supports Generation 2 using the [`az aks nodepool update`][az-aks-nodepool-update] command. This update changes your node image from Generation 1 to Generation 2. |
| 60 | + |
| 61 | +```azurecli-interactive |
| 62 | +az aks nodepool update --resource-group <resource-group-name> --cluster-name <cluster-name> --name <node-pool-name> --vm-size <supported-generation-2-vm-size> --os-type Linux |
| 63 | +``` |
| 64 | + |
| 65 | +### [Windows node pool](#tab/windows-node-pool) |
| 66 | + |
| 67 | +If you're using a Generation 1 image, you can update your node pool to use Generation 2 by selecting a VM size that supports Generation 2 using the [`az aks nodepool update`][az-aks-nodepool-update] command. To specify that you want to use Generation 2, add a custom header `--aks-custom-headers UseWindowsGen2VM=true`. Generation 2 VM also requires Windows Server 2022. This update changes your node image from Generation 1 to Generation 2. |
| 68 | + |
| 69 | +```azurecli-interactive |
| 70 | +az aks nodepool update --resource-group <resource-group-name> --cluster-name <cluster-name> --name <node-pool-name> --vm-size <supported-generation-2-vm-size> --os-type Windows --os-sku Windows2022 --aks-custom-headers UseWindowsGen2VM=true |
| 71 | +``` |
| 72 | +--- |
| 73 | + |
| 74 | +## Check if you're using a Generation 2 node image |
| 75 | + |
| 76 | +Verify a successful node pool creation using the [`az aks nodepool show`][az-aks-nodepool-show] command and check that the `nodeImageVersion` contains `gen2` in the output. |
| 77 | + |
| 78 | +```azurecli-interactive |
| 79 | +az aks nodepool show --resource-group <resource-group-name> --cluster-name <cluster-name> --name <node-pool-name> |
| 80 | +``` |
| 81 | + |
| 82 | +## Next steps |
| 83 | + |
| 84 | +To learn more about Generation 2 VMs, see [Support for Generation 2 VMs on Azure](../virtual-machines/generation-2.md). |
| 85 | + |
| 86 | +<!-- LINKS --> |
| 87 | +[az-aks-nodepool-add]: /cli/azure/aks/nodepool#az_aks_nodepool_add |
| 88 | +[az-aks-nodepool-show]: /cli/azure/aks/nodepool#az_aks_nodepool_show |
| 89 | +[az-aks-nodepool-update]: /cli/azure/aks/nodepool#az_aks_nodepool_update |
| 90 | +[create-node-pools]: ./create-node-pools.md |
| 91 | +[az-vm-list-skus]: /cli/azure/vm#az_vm_list_skus |
0 commit comments