We have a managed instance group on GCP which is configured with an autoscaling rule.
The instance group references an instance template that was created via gcloud compute instance-templates create-with-container
. The container image is hosted on GCR.
I'm trying to understand the best way to deploy frequent updates to this instance group, for example in a CI/CD pipeline.
Based on my current understanding, it seems the procedure is:
- Build and push a new docker image to GCR
- Create a new instance template.
- Submit a rolling update to the instance group which points at the new instance template.
However in a CI/CD pipeline, it seems:
- This is going to create hundreds, potentially thousands of dangling instance templates that are only used once and never again. Is there a problem with this?
- Its unclear how the instance templates should be named or versioned. I was thinking of writing a hash of the docker image into the instance template name when the template is created, but this seems needlessly manual.
Is this really the optimal way to deploy updates to an instance group, or am I missing something? Does deployment manager simplify this all, for example in the name generation or template cleanup?