加载命名空间时出错。未经授权:验证您有权访问 Kubernetes 集群

ope*_*per 13 amazon-web-services kubernetes amazon-eks

我已经使用命令行 eksctl 创建了一个 EKS 集群,并验证了该应用程序运行正常。

但是注意到一个奇怪的问题,当我尝试在 Web 浏览器中访问集群中的节点时,我看到以下错误

Error loading Namespaces
Unauthorized: Verify you have access to the Kubernetes cluster
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我能够看到节点使用 kubectl get nodes

我以管理员用户身份登录。关于如何解决这个问题的任何帮助都会非常好。谢谢。

小智 7

您需要将您的 IAM 角色/用户添加到集群的 aws-auth 配置映射

https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html采取的基本步骤

kubectl edit -n kube-system configmap/aws-auth
Run Code Online (Sandbox Code Playgroud)
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
  mapRoles: |
    - rolearn: <arn:aws:iam::111122223333:role/eksctl-my-cluster-nodegroup-standard-wo-NodeInstanceRole-1WP3NUE3O6UCF>
      username: <system:node:{{EC2PrivateDNSName}}>
      groups:
        - <system:bootstrappers>
        - <system:nodes>
  mapUsers: |
    - userarn: <arn:aws:iam::111122223333:user/admin>
      username: <admin>
      groups:
        - <system:masters>
    - userarn: <arn:aws:iam::111122223333:user/ops-user>
      username: <ops-user>
      groups:
        - <system:masters>
Run Code Online (Sandbox Code Playgroud)