aws cli:update-kubeconfig 未按预期工作

aws cli: update-kubeconfig not working as expected

我正在尝试使用下面提到的 CLI 更新 kubeconfig 文件

aws eks update-kubeconfig --name EKS_cluster

给我这个错误

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help
aws: error: argument operation: Invalid choice, valid choices are:

create-cluster                           | delete-cluster
describe-cluster                         | list-clusters
help

我使用的was cli版本是

aws-cli/1.15.58 Python/3.5.2 Linux/5.3.0-1030-aws botocore/1.10.57

有人可以帮我解决这个问题吗?

来自为 Amazon EKS 创建 kubeconfig 的文档 here

Ensure that you have version 1.16.156 or later of the AWS CLI installed.

显然这是因为 CLI 的旧版本 (1.15.58)。升级 CLI 应该可以解决这个问题。

此外,现在 CLI 已经有了版本 2,您可以从 here

安装它

您的 AWS-CLI 版本需要更新。至少您需要 运行 AWS-CLI 版本 1.16.156,如 AWS Docs.

中所述

Amazon EKS uses the aws eks get-token command, available in version 1.16.156 or later of the AWS CLI or the AWS IAM Authenticator for Kubernetes with kubectl for cluster authentication.

您还需要确保已安装 AWS IAM Authenticator 以便使用角色进行身份验证。

Download the Amazon EKS-vended aws-iam-authenticator binary from Amazon S3. To download the ARM version, change amd64 to arm64 before running the command. curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.17.7/2020-07-08/bin/linux/amd64/aws-iam-authenticator

Apply execute permissions to the binary. chmod +x ./aws-iam-authenticator

Copy the binary to a folder in your $PATH. We recommend creating a $HOME/bin/aws-iam-authenticator and ensuring that $HOME/bin comes first in your $PATH. mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$PATH:$HOME/bin

Add $HOME/bin to your PATH environment variable. echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc

Test that the aws-iam-authenticator binary works. aws-iam-authenticator help