Go back

Auto starting VMs in other project

This section describes how to use Money Saver VM to autostart preemptible vms from other projects.

  1. Make sure Money-Saver VM is deployed and up and running in the project as perGCP Getting Started Guide .

money-saver-vm-provisioned-home-project

  1. Provision preemptible vms in other projects.
  2. 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

/img/gcp/money-saver-vm/money-saver-metadata.png

  1. 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

/img/gcp/money-saver-vm/money-saver-service-key.png

Updating other project with Money-Saver service key:

  • Now go to the other project, open IAM console (by typing IAM in the search box)

/img/gcp/money-saver-vm/IAM-console-01.png

  • Click on Add

/img/gcp/money-saver-vm/IAM-console.png

  • paste the Money-Saver service key into “New Member” box

/img/gcp/money-saver-vm/money-saver-IAM-role.png

  • Select “Compute Admin” from “Role” drop down

/img/gcp/money-saver-vm/money-saver-IAM-role-01.png

  • 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.
  1. Now preemptible vms from other projects will autostart with the Money Saver VM

  2. You can monitor Money-Saver VM log available at /var/log/money-saver-vm.log for restart activities

/img/gcp/money-saver-vm/log-file.png

  1. 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.

/img/gcp/money-saver-vm/money-saver-autostart-no.png

Go back