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

相關文章
相關標籤/搜索