Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto update/pull docker image on GCP Instance Groups with Container-Optimized OS

I have a instance on GCP running in Instance Group with a Container-Optimized OS using a single image hosted on GCR.

I want to pull a new image to GCP, and refresh the instance image with that new image. I'm building and pushing over GitHub Actions and can call some gcloud command inside the CI workflow.

I want to say "hey Instance Group, do pull again the container imagens". It would be good to do this keeping the service running.

What should be the best approach to do that? What full gcloud command to do that?

like image 740
Tiago Gouvêa Avatar asked May 10 '26 07:05

Tiago Gouvêa


1 Answers

The steps are:

  1. Prepare a new Docker image.
  2. Create an instance template based upon the new Docker image.
  3. Update the MIG (Managed Instance Group).

Create an instance template:

gcloud compute instance-templates create-with-container [TEMPLATE_NAME] --container-image [DOCKER_IMAGE]

Update the MIG:

gcloud compute instance-groups managed rolling-action start-update [MIG_NAME] --version template=[TEMPLATE_NAME]

You can read more about configuring the available options for your update here.

like image 53
John Hanley Avatar answered May 13 '26 17:05

John Hanley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!