0

I am trying to set up a Load Balancer on GCP which deploys new VMs with a copy of my application when the health check fails. Is using the startup script a safe solution for deploying copies of my application on the VM?

My thought is to host a zipped copy of my application and store it on a remote server and retrieve and unzip it on each new VM as it's deployed.

#! /bin/bash
apt update
apt upgrade -y
apt install -y php apache2 unzip
curl https://example.com/application.zip -L -o /var/www/html/application.zip
unzip /var/www/html/application.zip
epool
  • 266
  • 1
  • 13
  • 1
    Hi, yes, you can try that or even use a [startup-script-url](https://cloud.google.com/compute/docs/startupscript#using-a-local-startup-script-file) save your configurations to Cloud Storage. Also you can try a [Managed Instance Group](https://cloud.google.com/compute/docs/instance-groups/working-with-managed-instances) approach, which allows yo to create a template of your instance and create as many VM Instances as required based on this Template. – Hi_Esc Mar 30 '21 at 20:18

1 Answers1

1

This document describes the procedure to deploy an External HTTP(s) load balancer with a Compute Engine backend:

https://cloud.google.com/load-balancing/docs/https/ext-https-lb-simple

You can use your own startup script in all deployed VM's when they are autoscale.

The process is as follow:

  • Create a Managed Instance group based on a template.
  • Add a named port to the instance group.
  • Configure a firewall rule for the health-checks.
  • Reserve an external IP address for the Load Balancer.
  • Setting up the load balancer.
Edd
  • 86
  • 5