从 GCE 中的虚拟机中,我执行了以下操作
gcloud auth activate-service-account --key-file <blah>
# "blah" is a service account key file (JSON) I generated from the web interface
gcloud config set project <project-name>
gcloud config set compute/zone <zone-name>
gcloud set container/cluster <cluster-name>
然后当我尝试运行
gcloud container clusters get-credentials <cluster-name>
失败并显示错误消息:
Error message: "ERROR: (gcloud.container.clusters.get-credentials) ResponseError: code=403, message=Request had insufficient authentication scopes."
虚拟机与 GKE 集群位于同一网络。我尝试了同样的操作,使用来自 GCE 外部计算机的相同服务帐户 key 文件,针对“默认”网络上的 GKE 集群,并且成功了...
最佳答案
要从 GCE 虚拟机使用 Google Kubernetes Engine API,您需要在创建虚拟机时将云平台范围(“https://www.googleapis.com/auth/cloud-platform ”)添加到虚拟机中。
关于google-cloud-platform - 403 "Request had insufficient authentication scopes"在 gcloud 容器集群获取凭据期间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35928534/