GCP Cloud 运行 无法从其他项目的 Artifact Registry 中提取图像

GCP Cloud Run Cannot Pull Image from Artifact Registry in Other Project

我有一个 parent 项目,其中为 docker 配置了工件注册表。

一个 child 项目有一个云 运行 服务需要从 parent.

child 项目还有一个服务帐户,该帐户被授权通过 IAM 角色访问存储库 roles/artifactregistry.writer.

当我尝试启动我的服务时,我收到一条错误消息:

Google Cloud Run Service Agent must have permission to read the image, europe-west1-docker.pkg.dev/test-parent-project/docker-webank-private/node:custom-1. Ensure that the provided container image URL is correct and that the above account has permission to access the image. If you just enabled the Cloud Run API, the permissions might take a few minutes to propagate. Note that the image is from project [test-parent-project], which is not the same as this project [test-child-project]. Permission must be granted to the Google Cloud Run Service Agent from this project.

我已经测试了手动连接 docker login 并使用服务帐户的私钥和 docker pull 命令在我的电脑上运行完美。

cat $GOOGLE_APPLICATION_CREDENTIALS | docker login -u _json_key --password-stdin https://europe-west1-docker.pkg.dev
> Login succeeded
docker pull europe-west1-docker.pkg.dev/bfb-cicd-inno0/docker-webank-private/node:custom-1
> OK

服务账号也绑定到云端运行服务:

您在云中使用了 2 种类型的服务帐户 运行:

  • Google云运行API服务帐号
  • 运行时间服务帐户。

在您的解释和屏幕截图中,您谈到了运行时服务帐户,服务运行时将使用的身份,并调用 Google Cloud API。

BUT 在 运行 之前,必须部署服务。这一次,Google 云 运行 内部流程 运行 拉取容器、创建修订并执行所有必需的内部操作。为了完成这项工作,还存在一个服务帐户,它被命名为“服务代理”。

在IAM控制台可以找到:格式如下

service-<PROJECT_NUMBER>@serverless-robot-prod.iam.gserviceaccount.com

不要忘记勾选右上角的复选框以包含 Google 托管服务帐户

如果您希望此部署服务帐户能够在另一个项目中拉取图像,请在其上授予正确的权限,而不是在运行时服务帐户上。