Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Instance Group with preconfigured VMs (not with startup scripts)

Dear Team

as i am new to this .. please excuse me if this is a basic query..

i am trying to understand how to create a instance group .. when we have a custom VM which has some Apps / libraries / software installed.. for now my understanding is instance groups can only use instance templates.. and when we configure instance templates its just the VM configuration with a startup script .. but what if we need a VM which has preinstalled setup / apps etc ... can i use a preconfigured VM to create Managed instance group .. i want instance group to create and manage my VMs and do not want to select Vms created as a separate step. 

 

Please advise. 

0 5 349
5 REPLIES 5

Hi,

yes. You can.
1. You have to create snapshot from existing VM.
2. Then you need to create your own image from that snapshot.
3. At the end, in "Instance template" creation you need to choose Boot disk and from custom images choose your previously created custom image. 
4. Once template is created, you can create MIGs from this template 🙂 Should work 🙂 

best,
DamianS

Let me try this boss and i share the update by tmrw

Sure,

if you need any help, you can ping me in DM.

I do this and place the image created in an image family with the group template designed to pull the latest image from that family. The process of creating an instance group template that uses your image family can't be done in the console AFAIK and has to be done with the cloud sdk cli or possibly some direct API calls (which I've not tried to do)
When you create the image specify the image family name with a command like this
 

gcloud compute images create $OS_IMAGE_NAME --source-disk $SOURCE_VM --source-disk-zone $SOURCE_VM_ZONE --family $IMAGE_FAM --storage-location us --project $PROJECT_ID

 Each new image you create for the same family will be in effect placed in a queue for the template to pull just the latest one. You can also deprecate the latest image in a family to effect a rollback.
Create a template that uses that family with something like this:

gcloud compute instance-templates create $templateName --image-family $imagefamily  --tags="$joinedtags" $imageproject --custom-cpu=$cpus --custom-memory=$memory --scopes="$SCOPES" --metadata="$joinedmd" --network $network --project ${target_proj} --boot-disk-size "${DISKSIZE}GB"



I still use startup scripts though, so that specific configurations can be applied in the different contexts in which vm's use the same image family