Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

CI/CD with development versions for cloud run

Is anyone else deploying development/branch versions of cloud run services? 

I had this set up for app engine with --no-promote, and that works quite well, and development versions are super useful for testing and comparing.

However on cloud run I ended up with this rather awkward set of commands in the pipeline, essentially having to stop deployments promoting on every dev branch, and then force an update by update-traffic on a prod deployment.

Anyone doing this and found a better way?

gcloud builds submit --tag gcr.io/chatdesk-ml/<image>
params=(--image gcr.io/<project>/<image>:latest --region us-central1 --allow-unauthenticated --execution-environment=gen1)
if [ "${BITBUCKET_BRANCH}" != "master" ]; then params+=(--no-traffic --tag=$BITBUCKET_BRANCH --revision-suffix=dev-${BITBUCKET_BUILD_NUMBER}); else params+=(--tag=prod --revision-suffix=prod-${BITBUCKET_BUILD_NUMBER});fi 
gcloud beta run deploy <service> "${params[@]}"
if [ "${BITBUCKET_BRANCH}" == "master" ]; then gcloud run services update-traffic <service> --to-latest; fi  # if prod, set traffic to go there

 

0 4 823
4 REPLIES 4

Since it was your desired configuration, can you share the commands you originally used to deploy through App Engine for reference?

We use this: https://bitbucket.org/atlassian/google-app-engine-deploy/src/master/

With PROMOTE set accordingly (true on master, false on dev*) and VERSION set to (prod-#### on master, branch name on dev*). This just sets --promote or --no-promote as you can see in pipe/pipe.sh, and it is these flags that don't appear to have convenient equivalents on cloud run.

For this scenario, you can submit a feature request for the gcloud CLI to request similar options as those you were using with your App Engine deployments. This is so these features can be implemented in a possible future release. As of now, one recommended practice you can use is to organize your development and production releases into different projects, or you could rely on deployment tools like Terraform to manage data between each of your environments.