Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set "imagePullPolicy" for Cloud Run Service?

I would like to be able to automatically update my Google Cloud Run Services once my image has been updated on Google Container Registry.

I need to update multiple Cloud Run services based on the same image (which has a tag of :latest ), so I expected this to work.

  # build & push the container image
- name: "gcr.io/kaniko-project/executor:latest"
  args: ["--cache=true", "--cache-ttl=48h", "--destination=gcr.io/project/titan:latest"]

Currently, my titan image gets updated but no new Revision is deployed to Cloud Run.

like image 503
Tim Avatar asked Oct 21 '25 12:10

Tim


1 Answers

Google Cloud Run does not automatically deploy a revision when you push a new image to a tag reference. There are many good reasons it doesn’t.

When a Cloud Run revision is deployed, it computes the sha256 hash of the image reference.

Therefore when you specify a container image with :latest tag, Cloud Run uses its sha256 reference to deploy and scale out that revision of your service. When you update :latest tag to point to the new image, Cloud Run will still use the previous image. It would be a dangerous and slippery slope otherwise.

If you need to auto-deploy new revisions to Cloud Run based on a new image push, I recommend two solutions:

  1. Make “gcloud beta run deploy” command a step in your Google Cloud Build process. (easy) https://cloud.google.com/run/docs/continuous-deployment
  2. Write a GCF/Run service that deploys your app to Cloud Run every time there’s a new image pushed by subscribing to Google Cloud Build (or GCR) notifications through PubSub. (much harder)
like image 152
ahmet alp balkan Avatar answered Oct 23 '25 09:10

ahmet alp balkan