gpt4 book ai didi

kubernetes - aws-iam-authenticator & EKS

转载 作者:行者123 更新时间:2023-12-02 12:01:37 24 4
gpt4 key购买 nike

我已经使用适当的 configMap 部署了一个测试 EKS 集群,并且 SSO 的用户可以通过导出 session 凭据(AWS_ACCESS_KEY_ID、SECRET_ACCESS_KEY_ID、AWS_SESSION_TOKEN 等)并在他们的终端中安装 aws-iam-authenticator 客户端来访问集群.当用户尝试使用 aws sso 时,问题就出现了。配置文件存储在 ~/.aws/config使用 aws-iam-authenticator。运行任何 kubectl 时收到的错误命令如下:

 $ kubectl get all
could not get token: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors

我已经在我的本地机器(AWS CLI v2)上对此进行了测试,但没有取得任何成功。我已导出在 ~/.aws/config 中找到的 AWS 配置文件通过 export AWS_PROFILE=User1 提交文件并运行 aws sts get-caller-identity正确显示正在导出的配置文件。我已经在多个命名配置文件之间切换,每个配置文件都获得了正确的身份和权限,但是,当运行任何 kubectl 时命令我收到上述错误。我也尝试过符号链接(symbolic link) config -> credentials但没有运气。唯一可行的方法是将 access_key、secret_key 和 session_token 导出到环境变量。

我想我可以忍受必须粘贴来自 AWS SSO 的动态凭据,但我解决解决方案的需要不会让我放弃:(。我正在关注这个 github issue 中的线程,但没有运气. 我设置的 kube 配置文件是 AWS 文档中指定的。

我怀疑 aws-iam-authenticator 可能有问题服务器部署,但 pod 日志中没有显示任何内容。这是来自工具 github page 的片段, 我 think我正确地遵循了,但我确实跳过了第 3 步,原因我忘记了:

The Kubernetes API integrates with AWS IAM Authenticator for Kubernetes using a token authentication webhook. When you run aws-iam-authenticator server, it will generate a webhook configuration file and save it onto the host filesystem. You'll need to add a single additional flag to your API server configuration:



Kube 配置文件
apiVersion: v1
clusters:
- cluster:
server: <endpoint-url>
certificate-authority-data: <base64-encoded-ca-cert>
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: aws
name: aws
current-context: aws
kind: Config
preferences: {}
users:
- name: aws
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
command: aws-iam-authenticator
args:
- "token"
- "-i"
- "eks-cluster-name"
- "-r"
- "EKS-ADMIN-ROLE:ARN:::::::"
env:
- name: AWS_PROFILE
value: "USER"

最佳答案

AWS CLI v2 现在 supports AWS SSO 所以我决定更新我的 Kube 配置文件以利用 aws命令而不是 aws-iam-authenticator .现在通过 SSO 进行身份验证变得轻而易举!看起来 AWS 想要摆脱必须拥有额外的二进制文件才能在 EKS 集群中进行身份验证的情况,这对我来说很好!希望这可以帮助。

关于kubernetes - aws-iam-authenticator & EKS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61004524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com