将 UpdateClusterConfig 与 CLI 配合使用 - AWS SDK 代码示例

文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

UpdateClusterConfig 与 CLI 配合使用

以下代码示例演示如何使用 UpdateClusterConfig

CLI
AWS CLI

更新集群端点访问权限

此示例命令更新集群以禁用端点公有访问权限并启用私有端点访问权限。

命令:

aws eks update-cluster-config --name example \ --resources-vpc-config endpointPublicAccess=false,endpointPrivateAccess=true

输出:

{ "update": { "id": "ec883c93-2e9e-407c-a22f-8f6fa6e67d4f", "status": "InProgress", "type": "EndpointAccessUpdate", "params": [ { "type": "EndpointPublicAccess", "value": "false" }, { "type": "EndpointPrivateAccess", "value": "true" } ], "createdAt": 1565806986.506, "errors": [] } }

为集群启用日志记录

此示例命令为名为 example 的集群启用所有集群控制面板日志记录类型。

命令:

aws eks update-cluster-config --name example \ --logging '{"clusterLogging":[{"types":["api","audit","authenticator","controllerManager","scheduler"],"enabled":true}]}'

输出:

{ "update": { "id": "7551c64b-1d27-4b1e-9f8e-c45f056eb6fd", "status": "InProgress", "type": "LoggingUpdate", "params": [ { "type": "ClusterLogging", "value": "{\"clusterLogging\":[{\"types\":[\"api\",\"audit\",\"authenticator\",\"controllerManager\",\"scheduler\"],\"enabled\":true}]}" } ], "createdAt": 1565807210.37, "errors": [] } }
PowerShell
用于 PowerShell

示例 1:更新 Amazon EKS 集群配置。更新期间,您的集群将继续运行。

Update-EKSClusterConfig -Name "PROD" -Logging_ClusterLogging @{Types="api","audit","authenticator","controllerManager","scheduler",Enabled="True"}

输出

CreatedAt : 12/25/2019 5:03:07 PM Errors : {} Id : ee708232-7d2e-4ed7-9270-d0b5176f0726 Params : {Amazon.EKS.Model.UpdateParam} Status : InProgress Type : LoggingUpdate
  • 有关 API 的详细信息,请参阅 AWS Tools for PowerShell Cmdlet 参考UpdateClusterConfig中的。