
justinasb/aws-iam-authenticator-sso-wrapper该工具用于解决使用AWS SSO(AWS IAM Identity Center)角色对AWS EKS集群进行身份验证时遇到的问题。AWS原生支持使用AWS IAM角色对EKS进行身份验证,但需要提供角色ARN,且无法直接使用AWS SSO PermissionSet名称。
由PermissionSet创建的IAM角色包含随机后缀,当更新PermissionSet配置时这些后缀可能会变化,导致EKS访问权限丢失。在跨多个AWS账户管理多个EKS集群时,此问题尤为突出。该工具允许在aws-auth配置映射中使用PermissionSet名称替代角色ARN,自动将其转换为EKS集群所需的角色ARN格式,确保访问权限稳定。
kube-system命名空间中手动维护带有具体ARN的aws-auth配置映射yamlapiVersion: v1 kind: ConfigMap metadata: name: aws-auth namespace: kube-system data: mapAccounts: | [] mapRoles: | - "groups": - "system:masters" "rolearn": "arn:aws:iam::000000000000:role/AWSReservedSSO_AdminRole_0123456789abcdef" "username": "AdminRole:{{SessionName}}" mapUsers: | []
yamlapiVersion: v1 kind: ConfigMap metadata: name: aws-auth namespace: aws-iam-authenticator-sso-wrapper data: mapAccounts: | [] mapRoles: | - "groups": - "system:masters" "permissionset": "AdminRole" "username": "AdminRole:{{SessionName}}" mapUsers: | []
工具会处理其所在命名空间中的aws-auth配置映射,将permissionset字段转换为对应的角色ARN,并将结果保存到kube-system命名空间中,供EKS集群使用。
text❯ aws-iam-authenticator-sso-wrapper -h Usage of aws-iam-authenticator-sso-wrapper: -aws-region string 与IAM服务交互时使用的AWS区域(默认"us-east-1") -debug 启用调试日志 -dst-configmap string 转换后更新的目标Kubernetes配置映射名称(默认"aws-auth") -dst-namespace string 目标Kubernetes命名空间(默认"kube-system") -interval int 应用检查更新的时间间隔(秒)(默认1800) -src-configmap string 读取并进行转换的源Kubernetes配置映射名称(默认"aws-auth") -src-namespace string 读取包含PermissionSet名称的配置映射的Kubernetes命名空间,未定义时使用Pod的当前命名空间
Docker镜像可从Docker Hub获取:justinasb/aws-iam-authenticator-sso-wrapper
该应用需要列出AWS IAM角色的权限,因此需创建具有以下权限的IAM角色:
json{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": "iam:ListRoles", "Resource": "*" } ] }
信任策略配置(替换[AWS-ACCOUNT-ID]、[EKS-CLUSTER-REGION]、[EKS-CLUSTER-ID]为实际值):
json{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::[AWS-ACCOUNT-ID]:oidc-provider/oidc.eks.[EKS-CLUSTER-REGION].amazonaws.com/id/[EKS-CLUSTER-ID]" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "oidc.eks.[EKS-CLUSTER-REGION].amazonaws.com/id/[EKS-CLUSTER-ID]:sub": "system:serviceaccount:aws-iam-authenticator-sso-wrapper:aws-iam-authenticator-sso-wrapper" } } } ] }
txt> helm repo add aws-iam-authenticator-sso-wrapper [***] "aws-iam-authenticator-sso-wrapper" 已添加到您的仓库
txt> helm repo update 正在从您的图表仓库获取最新信息... ...成功从"aws-iam-authenticator-sso-wrapper"图表仓库获取更新
txt> helm install \ aws-iam-authenticator-sso-wrapper justinas-b/aws-iam-authenticator-sso-wrapper \ --namespace aws-iam-authenticator-sso-wrapper \ --create-namespace \ --set serviceaccount.annotations."eks\.amazonaws\.com/role-arn"=arn:aws:iam::123456789012:role/my-iam-role NAME: aws-iam-authenticator-sso-wrapper LAST DEPLOYED: 2023年10月2日 15:23:36 NAMESPACE: aws-iam-authenticator-sso-wrapper STATUS: deployed REVISION: 1 TEST SUITE: None
推荐使用AWS IRSA(IAM角色用于服务账户)进行AWS身份验证,也支持其他方式:
~/.aws/config)AWS_ACCESS_KEY_ID和AWS_SECRET_ACCESS_KEY)

manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务