I have a Google Compute Engine group, Group. I have changed the template that group uses repeatedly, it is now on Template5. The group has one instance, Instance, which is using a previous template (Template4). Template4 has been deleted and no longer exists. I do not see a way to force Instance to change templates. Things I have tried/have been blocked from trying:
So you cannot update an existing instance template or change an instance template after you create it. If you need to make changes to the configuration, create a new instance template. You can create a template based on an existing instance template, or based on an existing instance.
Instance template resources are immutable in GCP. You can edit/change the managed instance groups only by creating a new instance template.
Once you add the new template to the managed instance group either using the console or you can do it in gcloud by executing this command:
gcloud compute instance-groups managed set-instance-template \
<name-of-managed-instance-group> --template=<new-template-name> \
[--region=REGION | --zone=ZONE] [GLOBAL-FLAG …]
Now, all the instances that are to be created after adding this template, will follow the rules in instance template. But, this addition of instance template will not affect the existing instances in the group i.e the instances that use the old instance template. You need to recreate those instances by typing the following command in gcloud:
gcloud compute instance-groups managed recreate-instances \
<name-of-managed-instance-group> --instances \
<name-of-the-existing-instances-separated-by-comma>
[--region=REGION | --zone=ZONE] [GLOBAL-FLAG …]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With