Reputation: 69
I want to make a large number of cloud windows virtual machines, is there a way to install my application inside all of them and run and log in to my app, once.
a script, for example?
Upvotes: 0
Views: 77
Reputation: 2468
There are few steps that you need to follow to achieve this. The first step is to create customized Windows Server images
You can create customized Windows Server images from existing Compute Engine Windows Server images. Use these custom images to create instances with the same boot disk images as your existing instances.
Before creating your image you need to install GCESysprep
to prepare your system for duplication, also you can install all the programs you wanted before creating your image.
Then you can use the following command to create your image:
gcloud compute images create example-image --source-disk [DISK_NAME] \
--source-disk-zone [ZONE] \
--storage-location [LOCATION] \
[--force]
Once you have your image you can create your Instance Template. In this part of the process you can add a Start-up Sript by using unique, Windows-specific metadata keys.
Each metadata key must match the type of script you want to run.
Type of script | During GCESysprep & Before boot | After GCESysprep completes & On every subsequent boot |
---|---|---|
url startup scripts | sysprep-specialize-script-url | windows-startup-script-url |
cmd startup scripts | sysprep-specialize-script-cmd | windows-startup-script-cmd |
bat startup scripts | sysprep-specialize-script-bat | windows-startup-script-bat |
ps1 startup scripts | sysprep-specialize-script-ps1 | windows-startup-script-ps1 |
Then you can create an Instance Group using your Instance template, take in consideration that you can configure managed instance groups to automatically add or remove VMs based on their workloads.
gcloud compute instance-groups managed create [INSTANCE_GROUP_NAME] \
--size [SIZE] \
--template [INSTANCE_TEMPLATE] \
--zone [ZONE]
Upvotes: 1