我正在尝试在部署到 Google App Engine 的 RoR 应用程序中为 Cloud SQL 中的数据库加密环境变量。遵循此文档https://cloud.google.com/cloud-build/docs/securing-builds/use-encrypted-secrets-credentials
gcloud builds submit
但是,同时运行和时出现错误gcloud app deploy
。两者都是错误的:
失败状态:未知:错误响应:[4] DEADLINE_EXCEEDED / 构建步骤 0“gcr.io/cloud-builders/gcloud”失败:退出状态 1。
然后,我检查了gcloud builds described
应用程序无法部署的显示,但是DATABASE_PASS
显示工作/排队。我已将gcloud
sdk 中的 Cloud Build 组件增加到 1000 并测试超时:在cloudbuild.yaml;
这两个选项中都没有改善任何东西。
在使用 Cloud Build 之前,我的应用程序正在运行,但我消除了对凭据的需求,并将加密凭据用于 CI/CD 管道。另外,想在我的app.yaml
.
<cloudbuild.yaml>
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app','deploy','app-beta.yaml']
- name: 'us.gcr.io/project_ID/image_name'
#args: [ 'app', 'deploy', 'app-beta.yaml' ]
secretEnv: [ "DATABASE_PASS" ]
secrets:
- kmsKeyName: projects/Project_id/locations/global/keyRings/Misc/cryptoKeys/Random
secretEnv:
DATABASE_PASS:< base64 encoded encryption>
<app.yaml>
runtime: custom
env: flex
service: authentication
resources:
cpu: 2
memory_gb: 2.5
disk_size_gb: 10
beta_settings:
cloud_sql_instances: '/cloudsql/project_id:us-central1:sqlname'
network:
name: default
skip_files:
- .ruby-gemset
- .env
- .bundle
- .byebug_history
- .vscode/
- .idea/
- storage/
- vendor/
- log/
- tmp/
#liveness_check:
#path: '/liveness-check'
# initial_delay_sec: 300
# check_interval_sec: 30
# timeout_sec: 4
# failure_threshold: 2
# success_threshold: 2
#
# readiness_check:
# path: '/readiness-check'
# check_interval_sec: 5
# timeout_sec: 4
# failure_threshold: 2
# success_threshold: 2
# app_start_timeout_sec: 300
env_variables:
SECRET_KEY_BASE: 'SECRET_KEY'
RAILS_ENV: 'redacted'
RACK_ENV: 'redacted'
SERVICE_NAME: 'redacted'
REDIS_HOST: '10.0.0.3'
REDIS_PORT: 6379
TOTP_SECRET: 'TOTP_SECRET'
DATABASE_USER: 'postgres'
DATABASE_PASS: 'DATABASE_PASS'
DATABASE_NAME: 'postgres'
DATABASE_HOST: '/cloudsql/project_id:us-central1:sqlname'
RAILS_LOG_TO_STDOUT: enabled
RAILS_SERVE_STATIC_FILES: enabled
LANG: en_US.UTF-8