升級 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 the master components or a single, default node pool in an AKS cluster.

AKS 叢集使用多個節點的集區或 Windows Server 的節點 (包括目前處於預覽狀態,AKS 中),請參閱升級 AKS 中的節點集區For AKS clusters that use multiple node pools or Windows Server nodes (both currently in preview in AKS), see Upgrade a node pool in AKS.

開始之前Before you begin

本文會要求您執行 Azure CLI 2.0.65 版或更新版本。This article requires that you are running the Azure CLI version 2.0.65 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.11.x -> 1.12.x或是1.12.x -> 1.13.x允許,不過1.11.x -> 1.13.x不是。For example, upgrades between 1.11.x -> 1.12.x or 1.12.x -> 1.13.x are allowed, however 1.11.x -> 1.13.x is not.

若要升級,從1.11.x -> 1.13.x,首先從升級1.11.x -> 1.12.x,接著再升級從1.12.x -> 1.13.xTo upgrade, from 1.11.x -> 1.13.x, first upgrade from 1.11.x -> 1.12.x, then upgrade from 1.12.x -> 1.13.x.

下列範例輸出顯示,可以將叢集升級為版本1.12.7或是1.12.8:The following example output shows that the cluster can be upgraded to version 1.12.7 or 1.12.8:

Name     ResourceGroup    MasterVersion  NodePoolVersion  Upgrades
-------  ---------------  -------------  ---------------  --------------
default  myResourceGroup  1.11.9         1.11.9           1.12.7, 1.12.8

升級 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 將新節點新增至叢集來執行指定的 Kubernetes 版本,然後仔細cordon 和清空後其中一個要執行的中斷情況降到舊的節點應用程式。During the upgrade process, AKS adds a new node to the cluster that runs the specified Kubernetes version, then carefully cordon and drains one of the old nodes to minimize disruption to running applications. 確認新的節點做為執行中的應用程式 pod 時,就會刪除舊的節點。When the new node is confirmed as running application pods, the old node is deleted. 要等到升級叢集中所有節點之後,就會重複此程序。This process repeats until all nodes in the cluster have been upgraded.

下列範例會將叢集升級到版本1.12.8:The following example upgrades a cluster to version 1.12.8:

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

叢集升級需要幾分鐘的時間,具體取決於您擁有多少節點。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.12.8:The following example output shows that the cluster now runs 1.12.8:

Name          Location    ResourceGroup    KubernetesVersion    ProvisioningState    Fqdn
------------  ----------  ---------------  -------------------  -------------------  ---------------------------------------------------------------
myAKSCluster  eastus      myResourceGroup  1.12.8               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.