I use google cloud instance group with instance template (container registry) to manage many instances. But I have some problem with my MIG.
I set the container registry path to gcr.io/prok/server in my instance template.
I expect MIG to be updated automatically when I push new version docker image to container registry but it's not. MIG doesn't auto-update.
Many articles about MIG's said to create new instance template for update (v1->v2) and change instance template in MIG to new version template... but I want the MIG to automatically update without creating new instance template.
How do I do this?
It's possible to automate the entire process but it will require using Pub/Sub notifications to trigger the creation of the new temaplate:
When you update your image or upload a new one to Artifact Registry a pub-sub message will be generated and at this point the only thing is to check if there are new messages, for example with
gcloud(this is just an example):This of course has to be done using a dedicated VM that will be doing the checking and creating new temaples for your update; again you can create one with
gcloud:gcloud compute instance-templates create-with-container INSTANCE_TEMPLATE_NAME --container-image=CONTAINER_IMAGEAfter the template is ready you can run a rolling update:
I also found this answer describing the process but with the addition of Cloud Scheduler - you may find it quite informative.