我使用多种 Google 云服务。我工作的一些 Cloud Storage 存储桶位于项目 A 中,可以通过我自己的帐户访问,而另一些存储桶位于项目 B 中,我只能使用服务帐户访问。我激活了适当的服务帐户
gcloud auth activate-service-account --key-file mykey.json
在随后的登录过程中我只是使用
gcloud config set account service_account
我还需要切换我的活动项目,为此我使用了命令
gcloud config set project project-B
服务帐户工作得很好,允许我访问存储在 Google Cloud Storage 上的特定 bitbucket,但后来我需要使用 Argo 提交 kubernetes 工作流程,所以我使用以下命令切换回我的帐户和项目
gcloud config set account my_account
gcloud config set project project-A
Run Code Online (Sandbox Code Playgroud)
使用“gcloud auth list”我可以看到 my_account 处于活动状态
ACTIVE ACCOUNT
service_account.iam.gserviceaccount.com
* my_account
Run Code Online (Sandbox Code Playgroud)
但是当我尝试提交运行“kubectl -n default get services”时出现以下错误:
Error from server (Forbidden): services is forbidden: User "service_account.iam.gserviceaccount.com" cannot list resource "services" in API group "" in …Run Code Online (Sandbox Code Playgroud) permissions google-cloud-storage google-cloud-platform kubernetes