3

在创建资源之前启用 API 时,我们遇到了一个服务帐户“默认”到创建它的项目的问题。

SA 是在项目 A 下创建的,但它拥有Owner项目 B 的权限。

我们正在尝试在项目 B中创建一个资源(GKE 集群),但它抱怨我们需要首先在项目 A上启用 Kubernetes API (我们正在传递--project给集群创建命令以避免在我们尝试创建的位置出现任何歧义集群。get-credentials 命令也是如此)。

ERROR: (gcloud.container.clusters.create) ResponseError: code=403, message=Kubernetes Engine API has not been used in project PROJECT_NUMBER before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/container.googleapis.com/overview?project=PROJECT_NUMBER then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

PROJECT_NUMBER这里是项目 A 的数量,而不是 B。所需的 API 已经在项目 B 上启用。

我们在这里使用服务帐户的方法是否存在缺陷?

4

1 回答 1

2

Even though you're creating a cluster in project B, the caller of the API is project A (because the service account is owned by project A); therefore, the API must be enabled on project A.

于 2019-02-04T19:15:11.253 回答