升級 Azure Kubernetes Service (AKS) 節點映像
Azure Kubernetes Service (AKS) 會定期提供新的節點映像,以便於經常升級您的節點映像來使用最新的 AKS 功能。 Linux 節點映像會每週更新,而 Windows 節點映像會每月更新。 映像升級公告包含在 AKS 版本資訊中,而且可能需要一週的時間,這些更新才會在全部區域推出。 您也可以使用計劃性維護自動和排程執行節點映像升級。 如需詳細資訊,請參閱自動升級節點映像。
本文說明如何升級 AKS 叢集節點映像,以及如何在不升級 Kube 版本的情況下更新節點集區映像。 如需升級叢集 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.28
顯示為 latestNodeImageVersion
。
使用 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 環境的詳細資訊,請參閱 Kube 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
升級特定節點集區
若要在不執行 Kube 叢集升級的情況下更新節點集區的作業系統映像,請使用 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 環境的詳細資訊,請參閱 Kube 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
下一步
- 如需最新節點映像的相關資訊,請參閱 AKS 版本資訊。
- 了解如何使用升級 AKS 叢集來升級 Kubernetes 版本。
- 使用 GitHub Actions 自動套用叢集和節點集區升級。
- 藉由建立多個節點集區深入了解多個節點集區。
- 如需升級最佳做法和其他考量的詳細討論,請參閱 AKS 修補和升級指導。