403“gcloud容器集群get-credentials期间请求的认证范围不足”

问题描述 投票:23回答:2

从GCE的VM中,我做了以下操作

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>

它失败并显示错误消息:

错误消息:“错误:(gcloud.container.clusters.get-credentials)ResponseError:code = 403,message = Request的身份验证范围不足。”

VM与GKE集群位于同一网络中。我使用来自GCE外部的计算机的相同服务帐户密钥文件,针对“默认”网络上的GKE集群尝试了同样的事情,并且它成功...

google-cloud-platform google-kubernetes-engine
2个回答
32
投票

要从GCE虚拟机使用Google Kubernetes Engine API,您需要在创建虚拟机时将其添加到VM平台范围(“https://www.googleapis.com/auth/cloud-platform”)。


0
投票

如果您在GCP中使用来自VM的Google Kubernetes Engine API。首先需要在vm级别https://www.googleapis.com/auth/projecthosting,cloud-platform添加所需的范围。这也可以通过GCP控制台完成。停止VM实例,然后转到编辑选项,最后您将找到Cloud API访问范围。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.