docker - GCP Cloud Run 无法从其他项目的 Artifact Registry

我有一个项目,它有一个为 docker 配置的工件注册表。

一个项目有一个云运行服务,需要从拉取它的镜像。

项目还有一个服务帐户,该帐户被授权通过 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 命令在我的 PC 上完美运行。

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

服务帐户也附加到云运行服务:

最佳答案

您在 Cloud Run 中使用了 2 种类型的服务帐户:

  • Google Cloud Run API 服务帐户
  • 运行时服务帐户。

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

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

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

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

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

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

关于docker - GCP Cloud Run 无法从其他项目的 Artifact Registry 中拉取镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70433003/

相关文章:

r - 构建组中所有值的列表并应用于整个组

r - 将分区文件夹列转换为变量

c++ - 如何使用美元/欧元符号登录代码来初始化变量?

r - 计算数据框中给定变量的均值和标准差

nuget - nuget 的 GitHub Packages 服务身份验证问题

reactjs - 为什么 npm uninstall -g create-react-app 失败

android - 在 Jetpack Compose 中调用分页数据的刷新方法无法正常工作

python - 快速生成大规模随机ndarray的方法

go - Golang 中的全局变量

google-cloud-platform - 关于 Google Cloud Pub/Sub 消息