|
| 1 | +--- |
| 2 | +title: Upgrade Azure Kubernetes Service (AKS) node images |
| 3 | +description: Learn how to upgrade the images on AKS cluster nodes and node pools. |
| 4 | +ms.topic: how-to |
| 5 | +ms.custom: devx-track-azurecli, innovation-engine |
| 6 | +ms.subservice: aks-upgrade |
| 7 | +ms.service: azure-kubernetes-service |
| 8 | +ms.date: 09/20/2024 |
| 9 | +author: schaffererin |
| 10 | +ms.author: schaffererin |
| 11 | +--- |
| 12 | + |
| 13 | +## Environment Variables |
| 14 | + |
| 15 | +The following environment variables are declared and will be used in subsequent code blocks. They replace the placeholder parameters in the original document with standardized variable names. |
| 16 | + |
| 17 | +```bash |
| 18 | +export AKS_NODEPOOL="nodepool1" |
| 19 | +export AKS_CLUSTER="apache-airflow-aks" |
| 20 | +export AKS_RESOURCE_GROUP="apache-airflow-rg" |
| 21 | +``` |
| 22 | + |
| 23 | +# Upgrade Azure Kubernetes Service (AKS) node images |
| 24 | + |
| 25 | +Azure Kubernetes Service (AKS) regularly provides new node images, so it's beneficial to upgrade your node images frequently to use the latest AKS features. Linux node images are updated weekly, and Windows node images are updated monthly. Image upgrade announcements are included in the [AKS release notes](https://github.com/Azure/AKS/releases), and it can take up to a week for these updates to be rolled out across all regions. You can also perform node image upgrades automatically and schedule them using planned maintenance. For more information, see [Automatically upgrade node images][auto-upgrade-node-image]. |
| 26 | + |
| 27 | +This article shows you how to upgrade AKS cluster node images and how to update node pool images without upgrading the Kubernetes version. For information on upgrading the Kubernetes version for your cluster, see [Upgrade an AKS cluster][upgrade-cluster]. |
| 28 | + |
| 29 | +> [!NOTE] |
| 30 | +> The AKS cluster must use virtual machine scale sets for the nodes. |
| 31 | +> |
| 32 | +> It's not possible to downgrade a node image version (for example *AKSUbuntu-2204 to AKSUbuntu-1804*, or *AKSUbuntu-2204-202308.01.0 to AKSUbuntu-2204-202307.27.0*). |
| 33 | +
|
| 34 | +## Check for available node image upgrades |
| 35 | + |
| 36 | +1. Check for available node image upgrades using the [`az aks nodepool get-upgrades`][az-aks-nodepool-get-upgrades] command. |
| 37 | + |
| 38 | + ```azurecli-interactive |
| 39 | + az aks nodepool get-upgrades \ |
| 40 | + --nodepool-name $AKS_NODEPOOL \ |
| 41 | + --cluster-name $AKS_CLUSTER \ |
| 42 | + --resource-group $AKS_RESOURCE_GROUP |
| 43 | + ``` |
| 44 | +
|
| 45 | +1. In the output, find and make note of the `latestNodeImageVersion` value. This value is the latest node image version available for your node pool. |
| 46 | +1. Check your current node image version to compare with the latest version using the [`az aks nodepool show`][az-aks-nodepool-show] command. |
| 47 | +
|
| 48 | + ```azurecli-interactive |
| 49 | + az aks nodepool show \ |
| 50 | + --resource-group $AKS_RESOURCE_GROUP \ |
| 51 | + --cluster-name $AKS_CLUSTER \ |
| 52 | + --name $AKS_NODEPOOL \ |
| 53 | + --query nodeImageVersion |
| 54 | + ``` |
| 55 | +
|
| 56 | +1. If the `nodeImageVersion` value is different from the `latestNodeImageVersion`, you can upgrade your node image. |
| 57 | +
|
| 58 | +## Upgrade all node images in all node pools |
| 59 | +
|
| 60 | +1. Upgrade all node images in all node pools in your cluster using the [`az aks upgrade`][az-aks-upgrade] command with the `--node-image-only` flag. |
| 61 | +
|
| 62 | + ```text |
| 63 | + az aks upgrade \ |
| 64 | + --resource-group $AKS_RESOURCE_GROUP \ |
| 65 | + --name $AKS_CLUSTER \ |
| 66 | + --node-image-only \ |
| 67 | + --yes |
| 68 | + ``` |
| 69 | +
|
| 70 | +1. You can check the status of the node images using the `kubectl get nodes` command. |
| 71 | +
|
| 72 | + > [!NOTE] |
| 73 | + > This command might differ slightly depending on the shell you use. For more information on Windows and PowerShell environments, see the [Kubernetes JSONPath documentation][kubernetes-json-path]. |
| 74 | +
|
| 75 | + ```bash |
| 76 | + kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{"\n"}{end}' |
| 77 | + ``` |
| 78 | +
|
| 79 | +1. When the upgrade completes, use the [`az aks show`][az-aks-show] command to get the updated node pool details. The current node image is shown in the `nodeImageVersion` property. |
| 80 | +
|
| 81 | + ```azurecli-interactive |
| 82 | + az aks show \ |
| 83 | + --resource-group $AKS_RESOURCE_GROUP \ |
| 84 | + --name $AKS_CLUSTER |
| 85 | + ``` |
| 86 | +
|
| 87 | +## Upgrade a specific node pool |
| 88 | +
|
| 89 | +1. Update the OS image of a node pool without doing a Kubernetes cluster upgrade using the [`az aks nodepool upgrade`][az-aks-nodepool-upgrade] command with the `--node-image-only` flag. |
| 90 | +
|
| 91 | + ```azurecli-interactive |
| 92 | + az aks nodepool upgrade \ |
| 93 | + --resource-group $AKS_RESOURCE_GROUP \ |
| 94 | + --cluster-name $AKS_CLUSTER \ |
| 95 | + --name $AKS_NODEPOOL \ |
| 96 | + --node-image-only |
| 97 | + ``` |
| 98 | +
|
| 99 | +1. You can check the status of the node images with the `kubectl get nodes` command. |
| 100 | +
|
| 101 | + > [!NOTE] |
| 102 | + > This command may differ slightly depending on the shell you use. For more information on Windows and PowerShell environments, see the [Kubernetes JSONPath documentation][kubernetes-json-path]. |
| 103 | +
|
| 104 | + ```bash |
| 105 | + kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{"\n"}{end}' |
| 106 | + ``` |
| 107 | +
|
| 108 | +1. When the upgrade completes, use the [`az aks nodepool show`][az-aks-nodepool-show] command to get the updated node pool details. The current node image is shown in the `nodeImageVersion` property. |
| 109 | +
|
| 110 | + ```azurecli-interactive |
| 111 | + az aks nodepool show \ |
| 112 | + --resource-group $AKS_RESOURCE_GROUP \ |
| 113 | + --cluster-name $AKS_CLUSTER \ |
| 114 | + --name $AKS_NODEPOOL |
| 115 | + ``` |
| 116 | +
|
| 117 | +## Upgrade node images with node surge |
| 118 | +
|
| 119 | +To speed up the node image upgrade process, you can upgrade your node images using a customizable node surge value. By default, AKS uses one extra node to configure upgrades. |
| 120 | +
|
| 121 | +1. Upgrade node images with node surge using the [`az aks nodepool update`][az-aks-nodepool-update] command with the `--max-surge` flag to configure the number of nodes used for upgrades. |
| 122 | +
|
| 123 | + > [!NOTE] |
| 124 | + > To learn more about the trade-offs of various `--max-surge` settings, see [Customize node surge upgrade][max-surge]. |
| 125 | +
|
| 126 | + ```azurecli-interactive |
| 127 | + az aks nodepool update \ |
| 128 | + --resource-group $AKS_RESOURCE_GROUP \ |
| 129 | + --cluster-name $AKS_CLUSTER \ |
| 130 | + --name $AKS_NODEPOOL \ |
| 131 | + --max-surge 33% \ |
| 132 | + --no-wait |
| 133 | + ``` |
| 134 | +
|
| 135 | +1. You can check the status of the node images with the `kubectl get nodes` command. |
| 136 | +
|
| 137 | + ```bash |
| 138 | + kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{"\n"}{end}' |
| 139 | + ``` |
| 140 | +
|
| 141 | +1. Get the updated node pool details using the [`az aks nodepool show`][az-aks-nodepool-show] command. The current node image is shown in the `nodeImageVersion` property. |
| 142 | +
|
| 143 | + ```azurecli-interactive |
| 144 | + az aks nodepool show \ |
| 145 | + --resource-group $AKS_RESOURCE_GROUP \ |
| 146 | + --cluster-name $AKS_CLUSTER \ |
| 147 | + --name $AKS_NODEPOOL |
| 148 | + ``` |
| 149 | +
|
| 150 | +## Next steps |
| 151 | +
|
| 152 | +- For information about the latest node images, see the [AKS release notes](https://github.com/Azure/AKS/releases). |
| 153 | +- Learn how to upgrade the Kubernetes version with [Upgrade an AKS cluster][upgrade-cluster]. |
| 154 | +- [Automatically apply cluster and node pool upgrades with GitHub Actions][github-schedule]. |
| 155 | +- Learn more about multiple node pools with [Create multiple node pools][use-multiple-node-pools]. |
| 156 | +- Learn about upgrading best practices with [AKS patch and upgrade guidance][upgrade-operators-guide]. |
| 157 | +
|
| 158 | +<!-- LINKS - external --> |
| 159 | +[kubernetes-json-path]: https://kubernetes.io/docs/reference/kubectl/jsonpath/ |
| 160 | +
|
| 161 | +<!-- LINKS - internal --> |
| 162 | +[upgrade-cluster]: upgrade-aks-cluster.md |
| 163 | +[github-schedule]: node-upgrade-github-actions.md |
| 164 | +[use-multiple-node-pools]: create-node-pools.md |
| 165 | +[max-surge]: upgrade-aks-cluster.md#customize-node-surge-upgrade |
| 166 | +[auto-upgrade-node-image]: auto-upgrade-node-image.md |
| 167 | +[az-aks-nodepool-get-upgrades]: /cli/azure/aks/nodepool#az_aks_nodepool_get_upgrades |
| 168 | +[az-aks-nodepool-show]: /cli/azure/aks/nodepool#az_aks_nodepool_show |
| 169 | +[az-aks-nodepool-upgrade]: /cli/azure/aks/nodepool#az_aks_nodepool_upgrade |
| 170 | +[az-aks-nodepool-update]: /cli/azure/aks/nodepool#az_aks_nodepool_update |
| 171 | +[az-aks-upgrade]: /cli/azure/aks#az_aks_upgrade |
| 172 | +[az-aks-show]: /cli/azure/aks#az_aks_show |
| 173 | +[upgrade-operators-guide]: /azure/architecture/operator-guides/aks/aks-upgrade-practices |
0 commit comments