ℹ️ The explicit problem space mentioned in this article may no longer be an issue, but the concepts and practical tips discussed may still help you in other ways ✨
With Cloud Run now in general availability, you can now update to your deployment scripts. No longer must you call
gcloud beta run, now you can use just
... if you are running a version of
gcloud, using at least Google Cloud SDK 271.0.0.
And if you've been running Cloud Build with
--config, you might be using an older version.
When Cloud Build steps run, they often use Cloud Builders -- specially crafted docker containers. If you've already used one recently, it may be in your registry cache. This makes your builds faster (since it doesn't have to re-download the image), but it won't automatically get a new one if it exists.
To fix this, you'll have to specify the exact version of the image you want to use.
The information for the cloud builder in our case can be found by going to http://gcr.io/cloud-builders/gcloud. This automatically redirects us to a nice long view of the most recent image. This image updates nightly, so we can just grab the latest SHA and force our script to use that.
For the most recent image at time of writing, you'll need
gcr.io/cloud-builders/gcloud@sha256:4ea77d19d7336d5a8dc4ae0e609d7f5b45fca067c34b70d7ed6740af229392c6 (known to their friends as
4ea77d19d733). Clicking the 'Copy full image name' icon will enter this in your clipboard, which you can then use to change your config script.
What we'll end up with is a step in our
cloudbuild.yaml which looks something like this:
- id: 'deploy service' name: 'gcr.io/cloud-builders/gcloud@sha256:4ea77d19d7336d5a8dc4ae0e609d7f5b45fca067c34b70d7ed6740af229392c6' args: ['run', 'deploy', '[SERVICE-NAME]', '--image', 'gcr.io/$PROJECT_ID/[SERVICE-NAME]', '--region', '[REGION]','--platform', '[PLATFORM]']
You can always test the image by running a version check directly with Docker.
SHA=4ea77d19d7336d5a8dc4ae0e609d7f5b45fca067c34b70d7ed6740af229392c6 docker pull gcr.io/cloud-builders/gcloud@sha256:$SHA docker run --rm gcr.io/cloud-builders/gcloud@sha256:$SHA --version
📝 Be sure to also
gcloud components update to get the latest version of