简体   繁体   中英

GCP service to ssh and run a script on 10 Virtual Machines in GCE without using a bastion VM

In a GCP project, I have 10 virtual machines in GCE (runs sshd).

I have a need to run a script on each of the 10 virtual machines (in GCE) once an hour . I would like this to be centralized because number of VMs will grow over time and I do not want to have to do this on every single VM. In addition, I would want to analyze the data I get back in a central place.

However, I do not want to use a bastion VM, because I would like a cloud-native solution that does not require maintaining yet another virtual machine.

Which GCP service can do this?

I have looked into Cloud Run and Cloud Composer. I was not able to do this with Cloud Run, although that may be my own lack of familiarity with the product. Cloud Composer seems like a overkill.

As @JohnHanley mentioned, you will need to write code or scripts to launch commands on VMs dynamically because GCP doesn't have the type of service you require.

You may want to consider Cloud Identity-Aware Proxy (IAP) as it can be used for building your solution:

IAP helps to protect SSH access to your VMs without needing to provide your VMs with public IP addresses, and without having to set up bastion hosts.

For instance, you can check the enable IAP on Compute Engine guide.

You can also create a feature request for Google to consider implementing this solution.

Your best solution, with no additional charges , would be to:

  1. Use a start-up script on each GCE
  2. In order to set a CRON instruction to execute your script

crontab.guru can help you fin the CRON instruction, hourly is 0 * * * *

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM