

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 搭配使用 `UpdateClusterVersion` 與 CLI
<a name="eks_example_eks_UpdateClusterVersion_section"></a>

下列程式碼範例示範如何使用 `UpdateClusterVersion`。

------
#### [ CLI ]

**AWS CLI**  
**將名為 `my-eks-cluster` 的 Amazon EKS 叢集，更新為指定的 Kubernetes 版本**  
下列 `update-cluster-version` 範例會將 Amazon EKS 叢集更新為指定的 Kubernetes 版本。  

```
aws eks update-cluster-version \
    --name my-eks-cluster \
    --kubernetes-version 1.27
```
輸出：  

```
{
    "update": {
        "id": "e4091a28-ea14-48fd-a8c7-975aeb469e8a",
        "status": "InProgress",
        "type": "VersionUpdate",
        "params": [
            {
                "type": "Version",
                "value": "1.27"
            },
            {
                "type": "PlatformVersion",
                "value": "eks.16"
            }
        ],
        "createdAt": "2024-04-12T16:56:01.082000-04:00",
        "errors": []
    }
}
```
如需詳細資訊，請參閱《*Amazon EKS 使用者指南*》中的[更新 Amazon EKS 叢集 Kubernetes 版本](https://docs.aws.amazon.com/eks/latest/userguide/update-cluster.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateClusterVersion](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/eks/update-cluster-version.html)。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**範例 1：此 Cmdlet 會將 Amazon EKS 叢集更新為指定的 Kubernetes 版本。您的叢集會在更新期間繼續運作。**  

```
Update-EKSClusterVersion -Name "PROD-KUBE-CL" -Version 1.14
```
**輸出：**  

```
CreatedAt : 12/26/2019 9:50:37 AM
Errors    : {}
Id        : ef186eff-3b3a-4c25-bcfc-3dcdf9e898a8
Params    : {Amazon.EKS.Model.UpdateParam, Amazon.EKS.Model.UpdateParam}
Status    : InProgress
Type      : VersionUpdate
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [UpdateClusterVersion](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：此 Cmdlet 會將 Amazon EKS 叢集更新為指定的 Kubernetes 版本。您的叢集會在更新期間繼續運作。**  

```
Update-EKSClusterVersion -Name "PROD-KUBE-CL" -Version 1.14
```
**輸出：**  

```
CreatedAt : 12/26/2019 9:50:37 AM
Errors    : {}
Id        : ef186eff-3b3a-4c25-bcfc-3dcdf9e898a8
Params    : {Amazon.EKS.Model.UpdateParam, Amazon.EKS.Model.UpdateParam}
Status    : InProgress
Type      : VersionUpdate
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [UpdateClusterVersion](https://docs.aws.amazon.com/powershell/v5/reference)。

------