Редагувати

Поділитися через


Upgrade Azure Kubernetes Service (AKS) node images

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, 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.

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.

Note

The AKS cluster must use virtual machine scale sets for the nodes.

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).

Check for available node image upgrades

  1. Check for available node image upgrades using the az aks nodepool get-upgrades command.

    az aks nodepool get-upgrades \
        --nodepool-name <node-pool-name> \
        --cluster-name <cluster-name> \
        --resource-group <resource-group>
    
  2. In the output, find and make note of the latestNodeImageVersion value. This value is the latest node image version available for your node pool.

  3. Check your current node image version to compare with the latest version using the az aks nodepool show command.

    az aks nodepool show \
        --resource-group <resource-group> \
        --cluster-name <cluster-name> \
        --name <node-pool-name> \
        --query nodeImageVersion
    
  4. If the nodeImageVersion value is different from the latestNodeImageVersion, you can upgrade your node image.

Upgrade all node images in all node pools

  1. Upgrade all node images in all node pools in your cluster using the az aks upgrade command with the --node-image-only flag.

    az aks upgrade \
        --resource-group <resource-group> \
        --name <cluster-name> \
        --node-image-only
    
  2. You can check the status of the node images using the kubectl get nodes command.

    Note

    This command might differ slightly depending on the shell you use. For more information on Windows and PowerShell environments, see the Kubernetes JSONPath documentation.

    kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{"\n"}{end}'
    
  3. When the upgrade completes, use the az aks show command to get the updated node pool details. The current node image is shown in the nodeImageVersion property.

    az aks show \
        --resource-group <resource-group> \
        --name <cluster-name>
    

Upgrade a specific node pool

  1. Update the OS image of a node pool without doing a Kubernetes cluster upgrade using the az aks nodepool upgrade command with the --node-image-only flag.

    az aks nodepool upgrade \
        --resource-group <resource-group> \
        --cluster-name <cluster-name> \
        --name <node-pool-name> \
        --node-image-only
    
  2. You can check the status of the node images with the kubectl get nodes command.

    Note

    This command may differ slightly depending on the shell you use. For more information on Windows and PowerShell environments, see the Kubernetes JSONPath documentation.

    kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{"\n"}{end}'
    
  3. When the upgrade completes, use the az aks nodepool show command to get the updated node pool details. The current node image is shown in the nodeImageVersion property.

    az aks nodepool show \
        --resource-group <resource-group> \
        --cluster-name <cluster-name> \
        --name <node-pool-name>
    

Upgrade node images with node surge

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.

  1. Upgrade node images with node surge using the az aks nodepool update command with the --max-surge flag to configure the number of nodes used for upgrades.

    Note

    To learn more about the trade-offs of various --max-surge settings, see Customize node surge upgrade.

    az aks nodepool update \
        --resource-group <resource-group> \
        --cluster-name <cluster-name> \
        --name <node-pool-name> \
        --max-surge 33% \
        --no-wait
    
  2. You can check the status of the node images with the kubectl get nodes command.

    kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{"\n"}{end}'
    
  3. Get the updated node pool details using the az aks nodepool show to get the updated node pool details. The current node image is shown in the nodeImageVersion property.

    az aks nodepool show \
        --resource-group <resource-group> \
        --cluster-name <cluster-name> \
        --name <node-pool-name>
    

Next steps