amazon-web-services - 使用代入的 IAM 角色从 EKS pod 访问远程 EKS 集群
问题描述
我已经阅读了本指南,以允许在我的 EKS 集群上运行的一个 pod 使用 kubectl 访问远程 EKS 集群。
我目前正在我的集群中使用amazon/aws-cli运行一个 pod ,安装一个服务帐户令牌,它允许我根据上面的指南承担一个使用 kubernetes RBAC 配置的 IAM 角色。我已确保通过运行正确承担了角色,aws sts get-caller-identity
确实如此。
我现在已经安装了 kubectl 并像这样配置了 kube/config -
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <redacted>
server: <redacted>
name: <cluster-arn>
contexts:
- context:
cluster: <cluster-arn>
user: <cluster-arn>
name: <cluster-arn>
current-context: <cluster-arn>
kind: Config
preferences: {}
users:
- name: <cluster-arn>
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- --region
- us-east-2
- eks
- get-token
- --cluster-name
- <cluster-name>
- --role
- <role-arn>
command: aws
env: null
但是,我尝试使用 kubectl 执行的每个操作都会导致此错误 -
error: You must be logged in to the server (Unauthorized)
我不知道我配置错了什么,如果有任何关于如何获得更详细错误消息的想法,我将不胜感激。
解决方案
如果 AWS CLI 已经在使用您想要的角色的身份,则不需要在 kubeconfig 参数中指定--role
& 。<role-arn>
通过保留它们,您的角色aws sts get-caller-identity
将需要具有sts:AssumeRole
该角色的权限<role-arn>
。如果它们是相同的,那么角色需要能够假设自己——这是多余的。
所以我会尝试从中删除这些参数kubeconfig.yml
,看看它是否有帮助。
推荐阅读
- javascript - Expo Push Notifications:“错误:无法在设备上获取 GCM 令牌。”
- algorithm - 加权有向图最短路径的最佳方法
- c# - 一种阻止用户或程序退出控制台的方法
- spring-boot - 如何使用 springboot 在 couchbase 中存储 JSON 对象
- javascript - 将“点击”信号连接到指标
- android - 什么可能导致 java.lang.reflect.InvocationTargetException?(和 java.lang.NullPointerException)
- angular - Angular 组件使用另一个使用导入模块的组件 - 组织?
- vue.js - Vue / HTML标记中的意外标记
- python - 在 Python 中仅显示相关矩阵中的第一列
- scala - 使用 $ 方法调用引用 DataFrame 列名时出现 NullPointerException