小编Lin*_*ndy的帖子

从 Google Cloud Build 发出授权请求

我正在尝试在 Google Cloud Build 中设置部署街道。为此,我想:

  1. 运行单元测试
  2. 无流量部署到 Cloud Run
  3. 运行集成测试
  4. 在 Cloud Run 中迁移流量

我已经完成了大部分设置,但我的集成测试包括对 Cloud Run 的几次调用,以验证经过身份验证的调用返回 200 和未经身份验证的返回 401。我遇到的困难是从 Cloud Build 发出签名请求。手动部署和运行集成测试时,它们可以工作,但不能通过 Cloud Build。

理想情况下,我想像在 AWS 中一样使用 Cloud Build 服务帐户来调用 Cloud Run,但我找不到如何从 Cloud Runner 访问它。因此,我从 Secret Manager 中检索凭证文件。此凭据文件来自新创建的具有 Cloud Run Invoker 角色的服务帐户:

steps:
  - name: gcr.io/cloud-builders/gcloud
    id: get-github-ssh-secret
    entrypoint: 'bash'
    args: [ '-c', 'gcloud secrets version access latest --secret=name-of-secret > /root/service-account/credentials.json' ]
    volumes:
      - name: 'service-account'
        path: /root/service-account
...
  - name: python:3.8.7
    id: integration-tests
    entrypoint: /bin/sh
    args:
      - …
Run Code Online (Sandbox Code Playgroud)

python google-cloud-platform google-cloud-build

2
推荐指数
1
解决办法
144
查看次数