5

问候stackoverflow社区!第一次提问,长期用户。

我正在使用 Cloud Build Local 组件和 Secret Manager 在本地测试我的 cloudbuild.yaml 文件,但它在“availableSecrets”上失败了。

错误消息:加载配置文件时出错:cloudbuild.Build 中的未知字段“availableSecrets”

  • 操作系统平台:Windows 10/WSL2/Ubuntu 18.04
  • 云构建本地:v0.5.2
  • Docker 引擎:v20.10.2
  • Nodejs 版本:v14.15.3
  • NPM 版本:6.14.9
  • gcloud 版本:326.0.0
  • 已安装组件:[BigQuery 命令行工具、Cloud Datastore Emulator、Cloud SDK 核心库、Cloud Storage 命令行工具、Google Cloud Build Local Builder、gcloud Beta 命令]

Cloud Build 构建文件的文档:https : //cloud.google.com/cloud-build/docs/build-config 使用云构建配置机密的文档: https ://cloud.google.com/cloud-build/docs/ secure-builds/use-secrets 云构建本地文档:https ://cloud.google.com/cloud-build/docs/build-debug-locally

执行的步骤:

  1. 向 Secret Manager 添加了秘密
  2. 在 Cloud Build 和 Secrets Manager 之间启用 API
  3. 添加了 cloudbuild 服务帐户作为每个秘密密码的成员。
  4. 向 cloudbuild 用户添加了 IAM 权限 Secret Manager Secrets Accessor。我不知道我从哪里得到这些信息,但此时它是其他尝试使用 Secret Manager 和 cloudbuild 的残余。我不确定在此处应用访问权限与应用到 Secret Manager 密钥之间的区别。

命令:cloud-build-local --config=cloudbuild.staging.yaml --dryrun=false .

cloudbuild.staging.yaml:

- name: gcr.io/cloud-builders/npm
  entrypoint: 'npm'
  args: [ 'install' ]
- name: 'gcr.io/cloud-builders/gcloud'
  args: ["app", "deploy"]
  env:
  - 'DAO_FACTORY=datastore'
  - 'POLL_INTERVAL=15'
  - 'PROMPT=staging>'
  - 'ENVIRONMENT=staging'
  - 'NAMESPACE=staging'
  - 'RESET_DATASTORE=false'
  secretEnv: ['ADMIN_USER', 'SUPER_ADMINS', 'BOT_TOKEN']
availableSecrets:
  secretManager:
  - versionName: projects/{project token}/secrets/SYSTEM_USER/versions/1
    env: 'ADMIN_USER'
  - versionName: projects/{project token}/secrets/SUPER_ADMINS/versions/1
    env: 'SUPER_ADMINS'
  - versionName: projects/{project token}/secrets/BOT_TOKEN/versions/2
    env: 'BOT_TOKEN'```


Tag: cloud-build-local. I guess without reputation a meaningful tag cannot be created. Maybe an esteemed community member will create this as this may be specific to cloud-build-local only.
4

2 回答 2

1

Google Cloud Build 描述符文件中对 Google Secret Manager 的支持显然是非常新的,目前 cloud-build-local 组件似乎不支持;请参阅 Guillaume 关于功能一周前的评论。在 Cloud Build 中运行云构建描述符时,它可以正常工作。

于 2021-02-07T22:03:08.643 回答
0

gcloud我通过升级工具修复了类似的问题。

于 2021-05-15T05:45:41.347 回答