安装 aws-iam-authenticator
Amazon EKS 使用 IAM 向您的 Kubernetes 集群提供身份验证(通过适用于 Kubernetes 的 Amazon IAM 身份验证器kubectl
客户端配置为使用 Amazon EKS,方法为:安装适用于 Kubernetes 的 Amazon IAM 身份验证器,然后修改 kubectl 配置文件,以便使用它进行身份验证。
如果您正在运行 Amazon CLI 版本 1.16.156 或更高版本,则无需安装该身份验证器。相反,您可以使用 aws eks
get-token
命令。有关更多信息,请参阅手动创建 kubeconfig。
如果您无法使用 Amazon CLI 版本 1.16.156 或更高版本创建 kubeconfig
文件,则您可以在 macOS、Linux 或 Windows 上安装适用于 Kubernetes 的 Amazon IAM 身份验证器。
- macOS
-
使用 Homebrew 安装
aws-iam-authenticator
安装
的最简单方法是使用 Homebrewaws-iam-authenticator
。 -
如果您的 Mac 上尚未安装 Homebrew
,请使用以下命令安装它。 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
-
使用以下命令安装
aws-iam-authenticator
。brew install aws-iam-authenticator
-
测试
aws-iam-authenticator
二进制文件的工作原理。aws-iam-authenticator help
在 macOS 上安装
aws-iam-authenticator
也可以按照以下步骤安装 Amazon 提供的
aws-iam-authenticator
版本。-
从 Amazon S3 中下载 Amazon EKS 提供的
aws-iam-authenticator
二进制文件。curl -o aws-iam-authenticator https://amazon-eks.s3.cn-north-1.amazonaws.com.cn/1.21.2/2021-07-05/bin/darwin/amd64/aws-iam-authenticator
-
(可选)使用同一存储桶前缀中提供的 SHA-256 总和验证下载的二进制文件。
-
下载系统的 SHA-256 总和。
curl -o aws-iam-authenticator.sha256 https://amazon-eks.s3.cn-north-1.amazonaws.com.cn/1.21.2/2021-07-05/bin/darwin/amd64/aws-iam-authenticator.sha256
-
检查下载的二进制文件的 SHA-256 总和。
openssl sha1 -sha256 aws-iam-authenticator
-
将命令输出中生成的 SHA-256 总和与下载的
aws-iam-authenticator.sha256
文件进行比较。这两者应该匹配。
-
-
将执行权限应用于二进制文件。
chmod +x ./aws-iam-authenticator
-
将二进制文件复制到您的
$PATH
中的文件夹。我们建议创建一个$HOME/bin/aws-iam-authenticator
并确保$HOME/bin
首先显示在您的$PATH
中。mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$PATH:$HOME/bin
-
将
$HOME/bin
添加到PATH
环境变量。echo 'export PATH=$PATH:$HOME/bin' >> ~/.bash_profile
-
测试
aws-iam-authenticator
二进制文件的工作原理。aws-iam-authenticator help
-
- Linux
-
在 Linux 上安装
aws-iam-authenticator
-
从 Amazon S3 中下载 Amazon EKS 为您的硬件平台提供的
aws-iam-authenticator
二进制文件。curl -o aws-iam-authenticator https://amazon-eks.s3.cn-north-1.amazonaws.com.cn/1.21.2/2021-07-05/bin/linux/amd64/aws-iam-authenticator
curl -o aws-iam-authenticator https://amazon-eks.s3.cn-north-1.amazonaws.com.cn/1.21.2/2021-07-05/bin/linux/arm64/aws-iam-authenticator
-
(可选)使用您的硬件平台的同一存储桶前缀中提供的 SHA-256 总和验证下载的二进制文件。
-
下载系统的 SHA-256 总和。
curl -o aws-iam-authenticator.sha256 https://amazon-eks.s3.cn-north-1.amazonaws.com.cn/1.21.2/2021-07-05/bin/linux/amd64/aws-iam-authenticator.sha256
curl -o aws-iam-authenticator.sha256 https://amazon-eks.s3.cn-north-1.amazonaws.com.cn/1.21.2/2021-07-05/bin/linux/arm64/aws-iam-authenticator.sha256
-
检查下载的二进制文件的 SHA-256 总和。
openssl sha1 -sha256 aws-iam-authenticator
-
将命令输出中生成的 SHA-256 总和与下载的
aws-iam-authenticator.sha256
文件进行比较。这两者应该匹配。
-
-
将执行权限应用于二进制文件。
chmod +x ./aws-iam-authenticator
-
将二进制文件复制到您的
$PATH
中的文件夹。我们建议创建一个$HOME/bin/aws-iam-authenticator
并确保$HOME/bin
首先显示在您的$PATH
中。mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$PATH:$HOME/bin
-
将
$HOME/bin
添加到PATH
环境变量。echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc
-
测试
aws-iam-authenticator
二进制文件的工作原理。aws-iam-authenticator help
-
- Windows
-
在安装有 Chocolatey 的 Windows 上安装
aws-iam-authenticator
-
如果您尚未在 Windows 系统上安装 Chocolatey,请参阅安装 Chocolatey
。 -
打开 PowerShell 终端窗口并使用以下命令安装
aws-iam-authenticator
程序包:choco install -y aws-iam-authenticator
-
测试
aws-iam-authenticator
二进制文件的工作原理。aws-iam-authenticator help
在 Windows 上安装
aws-iam-authenticator
-
打开一个 PowerShell 终端窗口并从 Amazon S3 下载 Amazon EKS 提供的
aws-iam-authenticator
二进制文件。curl -o aws-iam-authenticator.exe https://amazon-eks.s3.cn-north-1.amazonaws.com.cn/1.21.2/2021-07-05/bin/windows/amd64/aws-iam-authenticator.exe
-
(可选)使用同一存储桶前缀中提供的 SHA-256 总和验证下载的二进制文件。
-
下载系统的 SHA-256 总和。
curl -o aws-iam-authenticator.sha256 https://amazon-eks.s3.cn-north-1.amazonaws.com.cn/1.21.2/2021-07-05/bin/windows/amd64/aws-iam-authenticator.exe.sha256
-
检查下载的二进制文件的 SHA-256 总和。
Get-FileHash aws-iam-authenticator.exe
-
将命令输出中生成的 SHA-256 总和与下载的 SHA-256 文件进行比较。二者应匹配,不过 PowerShell 输出是大写。
-
-
将二进制文件复制到您的
PATH
中的文件夹。如果 PATH 中有现有目录可用于命令行实用程序,请将二进制文件复制到该目录。否则,请完成以下步骤。-
为命令行二进制文件创建一个新目录,例如
C:\bin
。 -
将
aws-iam-authenticator.exe
二进制文件复制到新目录。 -
编辑用户或系统 PATH 环境变量,将新目录添加到 PATH 中。
-
关闭 PowerShell 终端并打开一个新的来选取新的 PATH 变量。
-
-
测试
aws-iam-authenticator
二进制文件的工作原理。aws-iam-authenticator help
-
如果您现有一个 Amazon EKS 集群,则为该集群创建一个 kubeconfig
文件。有关更多信息,请参阅 为 Amazon EKS 创建 kubeconfig。否则,请参阅 创建 Amazon EKS 集群 以创建新的 Amazon EKS 集群。