Tae*_*Tae 2 google-cloud-build
为了运行集成测试,我们在 GCB 的一个步骤中构建并启动一个新容器:
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'gcloud'
args: ['container', 'clusters', 'get-credentials', '$_GC_CLUSTER', '--zone', '$_GC_ZONE']
- name: 'nixery.dev/bash/...'
entrypoint: 'make' # test creates and runs a new container
args: ['test', '-C', '$_SERVICE']
Run Code Online (Sandbox Code Playgroud)
当然,这个新容器无法访问 GCB 的默认帐户服务,因此无法访问其他资源,例如 Google Cloud Storage。
我们可以在基本映像中包含另一个服务帐户凭据,但如果我们可以依赖 GCB 提供的凭据会更好。我尝试从父容器复制 Kubernetes 配置和 Google Cloud SDK 配置,但它不起作用,所以我想我走错了路。
这个答案提到使用--impersonate-service-accountwith gcloud auth configure-docker,但没有提供更多细节。我正在容器中运行上一个命令,我想在运行测试之前授予访问权限:
gcloud auth configure-docker --impersonate-service-account project-number-compute@developer.gserviceaccount.com
python3 -m pytest tests
Run Code Online (Sandbox Code Playgroud)
但我仍然收到身份验证错误。如果可能,我错过了什么?
| 归档时间: |
|
| 查看次数: |
360 次 |
| 最近记录: |