Auto starting VMs in other project
This section describes how to use Money Saver VM to autostart preemptible vms from other projects.
- Make sure Money-Saver VM is deployed and up and running in the project as perGCP Getting Started Guide .
- Provision preemptible vms in other projects.
- To start preemptible vms from other projects,edit the money-saver vm’s metadata as below:
- Goto Money-Saver vm project, edit Money-Saver vm and add below meta data to Money-Saver VM
- key=project1
- value=project-id of VM created in step 2
- Note : Make sure you add the project-id and not project name in the value above
Save the changes.
If there are more than one other project to auto-start Preemptible VMs, repeat step 2 for each of the other projects, update key value to project2, project3 and so on
- In order for Money-Saver VM to auto-start VMs from other project, the other project needs to authorize Money-Saver VM to control VMs within that project. This is done by adding Money-Saver VM’s service key to the other project as shown below.
- Getting Money-Saver VM’s service key:
Login to Money-Saver VM and run the command “gcloud auth list” and copy the service key as shown below
Updating other project with Money-Saver service key:
- Now go to the other project, open IAM console (by typing IAM in the search box)
- paste the Money-Saver service key into “New Member” box
- Select “Compute Admin” from “Role” drop down
- Click “Save” to save changes
- if you have more external project to auto-start pre-emptible vms, repeat above steps (a-e) for each of those projects to add Money-Saver VM’s service key.
-
Now preemptible vms from other projects will autostart with the Money Saver VM
-
You can monitor Money-Saver VM log available at /var/log/money-saver-vm.log for restart activities
- Just like for the home project, to skip any preemptible vm from auto start from other project, set a key autostart with a value no in that respective vms metadata.