尝试部署到 Google Cloud Run 时出现权限错误

Car*_*nez 8 google-cloud-platform google-cloud-run

尝试将映像部署到云运行时出现权限错误:

gcloud beta run deploy endpoints_proxy \
    --image="gcr.io/endpoints-release/endpoints-runtime-serverless:1.30.0" \
    --allow-unauthenticated
Run Code Online (Sandbox Code Playgroud)

这是错误:

ERROR: (gcloud.beta.run.deploy) User [email-goes-here] does not have permission to access namespace [project-id-goes-here] (or it may not exist): Cloud Run does not have permission to get access tokens for the default compute service account, 1088973916567-compute@developer.gserviceaccount.com. Please give Google Cloud Run Service Agent the permission iam.serviceAccounts.getAccessToken on the default compute service account.
Run Code Online (Sandbox Code Playgroud)

我的帐户具有所有者和编辑器权限,我什至尝试附加 Cloud Run Service Agent 角色。

我还尝试将这些角色添加到错误中列出的“默认计算服务帐户”中,但没有奏效。

Car*_*nez 16

错误消息非常具有误导性,发生错误是因为缺少Cloud Run Service Agent

创建以下服务帐户后:

Name: service-<account-id>@serverless-robot-prod.iam.gserviceaccount.com
Role: Google Cloud Run Service Agent
Run Code Online (Sandbox Code Playgroud)

问题就解决了。看起来 Cloud Run 需要此服务帐户才能工作,所以永远不要删除它 :)

  • 你能扩展这个答案吗?您如何创建服务帐户以及应用了哪些角色/权限?服务帐户是如何被删除的? (6认同)
  • 服务帐户被手动删除,这是一个错误。为了重新创建它,我只是使用了与其他具有 @serverless-robot 域的服务帐户代理相同的电子邮件前缀。唯一附加的角色是 Google Cloud Run 服务代理。 (2认同)
  • 胡萝卜,您不需要创建新的服务帐户。所描述的服务帐号已存在并由 GCP 管理。相反,请转到 Cloud Console 的 IAM 页面 (https://console.cloud.google.com/iam-admin/iam),然后点击窗口顶部的“添加”以添加服务帐号和角色。 (2认同)

小智 13

您应该启用Cloud Build 服务帐户的权限。除非你这样做,否则它不会起作用。

Google Cloud Console > Cloud Build > Cloud Build Settings > 启用对您正在使用的 GCP 服务的访问。(参见附图)

云构建面板

云构建面板 - 启用您想要的服务