升級 Azure Kubernetes Service (AKS) 叢集Upgrade an Azure Kubernetes Service (AKS) cluster

作為 AKS 叢集生命週期的一部分,您通常需要升級至最新的 Kubernetes 版本。As part of the lifecycle of an AKS cluster, you often need to upgrade to the latest Kubernetes version. 套用最新的 Kubernetes 安全性版本,或升級以取得最新的功能非常重要。It is important you apply the latest Kubernetes security releases, or upgrade to get the latest features. 本文會示範如何升級現有的 AKS 叢集。This article shows you how to upgrade an existing AKS cluster.

開始之前Before you begin

本文需要您執行 Azure CLI 2.0.56 版或更新版本。This article requires that you are running the Azure CLI version 2.0.56 or later. 執行 az --version 以尋找版本。Run az --version to find the version. 如果您需要安裝或升級,請參閱安裝 Azure CLIIf you need to install or upgrade, see Install Azure CLI.

檢查可用的 AKS 叢集升級Check for available AKS cluster upgrades

若要檢查哪些 Kubernetes 版本可用於您的叢集,請使用 az aks get-upgrades 命令。To check which Kubernetes releases are available for your cluster, use the az aks get-upgrades command. 下列範例會在名為 myResourceGroup 的資源群組中,查看名為 myAKSCluster 的叢集的可用升級:The following example checks for available upgrades to the cluster named myAKSCluster in the resource group named myResourceGroup:

az aks get-upgrades --resource-group myResourceGroup --name myAKSCluster --output table

注意

當您升級 AKS 叢集時,無法略過 Kubernetes 次要版本。When you upgrade an AKS cluster, Kubernetes minor versions cannot be skipped. 例如,允許 1.10.x -> 1.11.x1.11.x -> 1.12.x 之間的升級,但不允許 1.10.x -> 1.12.x 的升級。For example, upgrades between 1.10.x -> 1.11.x or 1.11.x -> 1.12.x are allowed, however 1.10.x -> 1.12.x is not.

若要從 1.10.x -> 1.12.x 升級,請先從 1.10.x -> 1.11.x 升級,然後從 1.11.x -> 1.12.x 升級。To upgrade, from 1.10.x -> 1.12.x, first upgrade from 1.10.x -> 1.11.x, then upgrade from 1.11.x -> 1.12.x.

下列範例輸出顯示叢集可以升級到版本 1.11.51.11.6The following example output shows that the cluster can be upgraded to version 1.11.5 or 1.11.6:

Name     ResourceGroup    MasterVersion    NodePoolVersion    Upgrades
-------  ---------------  ---------------  -----------------  --------------
default  myResourceGroup  1.10.12          1.10.12            1.11.5, 1.11.6

升級 AKS 叢集Upgrade an AKS cluster

透過適用於您的 AKS 叢集的可用版本清單,使用 az aks upgrade 命令進行升級。With a list of available versions for your AKS cluster, use the az aks upgrade command to upgrade. 在升級過程中,AKS 會將新節點新增至叢集,然後仔細地隔離並清空節點 (一次一個),將中斷執行中應用程式的情況降到最低。During the upgrade process, AKS adds a new node to the cluster, then carefully cordon and drains one node at a time to minimize disruption to running applications. 下列範例將叢集升級為版本 1.11.6The following example upgrades a cluster to version 1.11.6:

az aks upgrade --resource-group myResourceGroup --name myAKSCluster --kubernetes-version 1.11.6

叢集升級需要幾分鐘的時間,具體取決於您擁有多少節點。It takes a few minutes to upgrade the cluster, depending on how many nodes you have.

若要確認升級是否成功,請使用 az aks show 命令:To confirm that the upgrade was successful, use the az aks show command:

az aks show --resource-group myResourceGroup --name myAKSCluster --output table

下列範例輸出顯示叢集目前執行 1.11.6The following example output shows that the cluster now runs 1.11.6:

Name          Location    ResourceGroup    KubernetesVersion    ProvisioningState    Fqdn
------------  ----------  ---------------  -------------------  -------------------  ---------------------------------------------------------------
myAKSCluster  eastus      myResourceGroup  1.11.6               Succeeded            myaksclust-myresourcegroup-19da35-90efab95.hcp.eastus.azmk8s.io

後續步驟Next steps

本文說明如何升級現有的 AKS 叢集。This article showed you how to upgrade an existing AKS cluster. 若要深入了解部署和管理 AKS 叢集,請參閱教學課程集合。To learn more about deploying and managing AKS clusters, see the set of tutorials.