AWS EKS 执行 kubectl 时 error: You must be logged in to the server (Unauthorized)

在 AWS 上建立好 EKS 后,想要在本地用  kubectl 来管理 EKS,必须用 aws eks update-kubeconfig 来更新本地的 ~/.kube/config 文件或者 KUBECONFIG 环境变量指向的别的配置文件。git

好比说你建立 EKS 的用户在本地 ~/.aws/credentials 中的 profile 是 my-aws-profile, 那么完整的 update-kubeconfig 命令就是github

$ aws eks --profile my-aws-profile --region us-east-1 update-kubeconfig --name myeks-cluster
Updated context arn:aws:eks:us-east-1:069762108088:cluster/myeks-cluster in /Users/yanbin/.kube/configspa

再来执行 kubectl get pods 若是出现错误 error: You must be logged in to the server (Unauthorized),确定是由于你使用的 awscli 命令比较老(到底有多老呢?在 github 上已经没法追溯了,大概是 1.16.266 以前的)。大约生成的 ~/.kube/config 文件末尾像下面那样 阅读全文 >>code

相关文章
相关标签/搜索