升級 Azure Kubernetes Service (AKS) 節點映射

Azure Kubernetes Service (AKS) 會定期提供新的節點映射,因此經常升級您的節點映射,以使用最新的 AKS 功能會很有説明。 Linux 節點映射會每週更新,而 Windows 節點映射會每月更新。 映射升級公告包含在 AKS 版本資訊 ,而且可能需要一周的時間,這些更新才會在所有區域推出。 您也可以使用計劃性維護自動和排程節點映射升級。 如需詳細資訊,請參閱 自動升級節點映射

本文說明如何升級 AKS 叢集節點映射,以及如何在不升級 Kubernetes 版本的情況下更新節點集區映射。 如需升級叢集 Kubernetes 版本的資訊,請參閱 升級 AKS 叢集

注意

AKS 叢集必須使用節點的虛擬機器擴展集。

您無法將節點映射版本降級(例如 AKSUbuntu-2204 至 AKSUbuntu-1804,或 AKSUbuntu-2204-202308.01.0 降級為 AKSUbuntu-2204-202307.27.0 )。

檢查是否有可用的節點映射升級

使用 az aks nodepool get-upgrades 命令檢查可用的節點映射升級。

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

輸出會顯示 latestNodeImageVersion ,如下列範例所示:

{
  "id": "/subscriptions/XXXX-XXX-XXX-XXX-XXXXX/resourcegroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myAKSCluster/agentPools/mynodepool/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
}

範例輸出會顯示 AKSUbuntu-1604-2020.10.28latestNodeImageVersion

使用 az aks nodepool show 命令,比較最新版本與目前的節點映射版本。

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

您的輸出訊息看起來應類似下列範例:

"AKSUbuntu-1604-2020.10.08"

在此範例中,有可用的節點映射版本升級,從 版本 AKSUbuntu-1604-2020.10.08 到版本 AKSUbuntu-1604-2020.10.28

升級所有節點集區中的所有節點映射

使用 az aks upgrade 命令搭配 --node-image-only 旗標來升級節點映射。

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

您可以使用 命令來檢查節點映射 kubectl get nodes 的狀態。

注意

此命令可能會根據您使用的殼層稍有不同。 如需 Windows/PowerShell 環境的詳細資訊,請參閱 Kubernetes JSONPath 檔

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

升級完成時,請使用 az aks show 命令來取得更新的節點集區詳細資料。 目前的節點映像顯示在 nodeImageVersion 屬性中。

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

升級特定節點集區

若要在不進行 Kubernetes 叢集升級的情況下更新節點集區的 OS 映射,請使用 az aks nodepool upgrade 命令搭配 --node-image-only 旗標。

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

您可以使用 命令來檢查節點映射 kubectl get nodes 的狀態。

注意

此命令可能會根據您使用的殼層稍有不同。 如需 Windows/PowerShell 環境的詳細資訊,請參閱 Kubernetes JSONPath 檔

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

升級完成時,請使用 az aks nodepool show 命令來取得更新的節點集區詳細資料。 目前的節點映像顯示在 nodeImageVersion 屬性中。

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

使用節點激增升級節點映像

若要加速節點映射升級程式,您可以使用可自訂的節點激增值來升級節點映射。 根據預設,AKS 會使用一個額外的節點來設定升級。

如果您想要提高升級速度,請使用 az aks nodepool update 命令搭配 --max-surge 旗標來設定用於升級的節點數目。 若要深入瞭解各種 --max-surge 設定的取捨,請參閱 自訂節點激增升級

az aks nodepool update \
    --resource-group myResourceGroup \
    --cluster-name myAKSCluster \
    --name mynodepool \
    --max-surge 33% \
    --no-wait

您可以使用 命令來檢查節點映射 kubectl get nodes 的狀態。

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

使用 az aks nodepool show 來取得更新的節點集區詳細資料。 目前的節點映像顯示在 nodeImageVersion 屬性中。

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

下一步