对AWS eks集群进行kubectl身份验证

时间:2020-10-01 01:22:32

标签: amazon-web-services kubernetes kubectl amazon-eks

我尝试了所有可以让我的“谷歌”进入的解决方案

   aws eks --region $AWS_REGION update-kubeconfig --name $EKS_CLUSTER
   aws-iam-authenticator token -i $EKS_CLUSTER
   aws eks get-token --cluster-name $EKS_CLUSTER
   kubectl edit -n kube-system configmap/aws-auth
   curl -o aws-auth-cm.yaml.tmpl https://amazon-eks.s3.us-west-2.amazonaws.com/cloudformation/2020-08-12/aws-auth-cm.yaml
   cat aws-auth-cm.yaml.tmpl | sed 's\/<ARN of instance role (not instance profile)>\' "$EKS_CLUSTER_NODE_ROLE_ARN/g" > aws-auth-cm.yaml  - rm aws-auth-cm.yaml.tmpl
   kubectl apply -f aws-auth-cm.yaml
   kubectl config set-context $EKS_CLUSTER

但是我收到以下错误

$ cat ./k8s/deployment.yaml.tmpl | sed 's/\$ZONE_ID'"/a/g" | kubectl apply -f - 

error: You must be logged in to the server (the server has asked for the client to provide credentials)
ERROR: Job failed: exit code 1

1 个答案:

答案 0 :(得分:1)

我将从检查aws cli版本开始。如果不是最新版本,请对其进行更新。接下来,我将介绍https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html,看看IAM角色是否设置正确。