Azure Kubernetes 服务 (AKS) 节点映像升级Azure Kubernetes Service (AKS) node image upgrade

AKS 支持升级节点上的映像,以便你能够获取最新的操作系统和运行时更新。AKS supports upgrading the images on a node so you're up to date with the newest OS and runtime updates. AKS 每周提供一个带有最新更新的新映像,因此,建议定期升级节点的映像以使用最新功能,包括 Linux 或 Windows 补丁。AKS provides one new image per week with the latest updates, so it's beneficial to upgrade your node's images regularly for the latest features, including Linux or Windows patches. 本文介绍了在不升级 Kubernetes 版本的情况下如何升级 AKS 群集节点映像以及如何更新节点池映像。This article shows you how to upgrade AKS cluster node images and how to update node pool images without upgrading the version of Kubernetes.

有关 AKS 提供的最新映像的详细信息,请参阅 AKS 发行说明For more information about the latest images provided by AKS, see the AKS release notes.

有关如何升级群集的 Kubernetes 版本的信息,请参阅升级 AKS 群集For information on upgrading the Kubernetes version for your cluster, see Upgrade an AKS cluster.

备注

AKS 群集必须对节点使用虚拟机规模集。The AKS cluster must use virtual machine scale sets for the nodes.

检查节点池是否在最新节点映像上Check if your node pool is on the latest node image

可通过以下命令查看可供节点池使用的最新节点映像版本:You can see what is the latest node image version available for your node pool with the following command:

az aks nodepool get-upgrades \
    --nodepool-name mynodepool \
    --cluster-name myAKSCluster \
    --resource-group myResourceGroup

在输出中,可以看到 latestNodeImageVersion,如以下示例所示:In the output you can see the latestNodeImageVersion like on the example below:

{
  "id": "/subscriptions/XXXX-XXX-XXX-XXX-XXXXX/resourcegroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myAKSCluster/agentPools/nodepool1/upgradeProfiles/default",
  "kubernetesVersion": "1.17.11",
  "latestNodeImageVersion": "AKSUbuntu-1604-2020.10.28",
  "name": "default",
  "osType": "Linux",
  "resourceGroup": "myResourceGroup",
  "type": "Microsoft.ContainerService/managedClusters/agentPools/upgradeProfiles",
  "upgrades": null
}

因此,对于 nodepool1,可用的最新节点映像是 AKSUbuntu-1604-2020.10.28So for nodepool1 the latest node image available is AKSUbuntu-1604-2020.10.28. 现在,可以通过运行以下命令将其与节点池所用的当前节点映像版本进行比较:You can now compare it with the current node image version in use by your node pool by running:

az aks nodepool show \
    --resource-group myResourceGroup \
    --cluster-name myAKSCluster \
    --name mynodepool \
    --query nodeImageVersion

示例输出将是:An example output would be:

"AKSUbuntu-1604-2020.10.08"

因此在本例中,可以从当前的 AKSUbuntu-1604-2020.10.08 映像版本升级到最新的 AKSUbuntu-1604-2020.10.28 版本。So in this example you could upgrade from the current AKSUbuntu-1604-2020.10.08 image version to the latest version AKSUbuntu-1604-2020.10.28.

升级所有节点池中的所有节点Upgrade all nodes in all node pools

升级节点映像是使用 az aks upgrade 来完成的。Upgrading the node image is done with az aks upgrade. 若要升级节点映像,请使用以下命令:To upgrade the node image, use the following command:

az aks upgrade \
    --resource-group myResourceGroup \
    --name myAKSCluster \
    --node-image-only

在升级过程中,请使用下面的 kubectl 命令来检查节点映像的状态,以获取标签并筛选出当前节点映像信息:During the upgrade, check the status of the node images with the following kubectl command to get the labels and filter out the current node image information:

kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{"\n"}{end}'

升级完成后,请使用 az aks show 来获取更新后的节点池详细信息。When the upgrade is complete, use az aks show to get the updated node pool details. 当前节点映像在 nodeImageVersion 属性中显示。The current node image is shown in the nodeImageVersion property.

az aks show \
    --resource-group myResourceGroup \
    --name myAKSCluster

升级特定节点池Upgrade a specific node pool

升级节点池上的映像类似于升级群集上的映像。Upgrading the image on a node pool is similar to upgrading the image on a cluster.

若要在不执行 Kubernetes 群集升级的情况下更新节点池的 OS 映像,请使用以下示例中的 --node-image-only 选项:To update the OS image of the node pool without doing a Kubernetes cluster upgrade, use the --node-image-only option in the following example:

az aks nodepool upgrade \
    --resource-group myResourceGroup \
    --cluster-name myAKSCluster \
    --name mynodepool \
    --node-image-only

在升级过程中,请使用下面的 kubectl 命令来检查节点映像的状态,以获取标签并筛选出当前节点映像信息:During the upgrade, check the status of the node images with the following kubectl command to get the labels and filter out the current node image information:

kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.labels.kubernetes\.azure\.com\/node-image-version}{"\n"}{end}'

升级完成后,请使用 az aks nodepool show 来获取更新后的节点池详细信息。When the upgrade is complete, use az aks nodepool show to get the updated node pool details. 当前节点映像在 nodeImageVersion 属性中显示。The current node image is shown in the nodeImageVersion property.

az aks nodepool show \
    --resource-group myResourceGroup \
    --cluster-name myAKSCluster \
    --name mynodepool

后续步骤Next steps