Configuring HTTP(S) load balancing
Let's take an example where we create two VMs in different regions with the same tag, and test them for HTTP(S) load balancing:
- Use the following command to create a VM and allow HTTP(S) traffic to it. Here, we are installing Debian on the VM and running commands such as updating it, installing Apache on it, and hosting a simple web page on it. You can name these instances sequentially for convenience, for example,
www-1
,www-2
, and so on:
gcloud compute instances create <<<first-instance-name>>> \ --image-family debian-8 \ --image-project debian-cloud \ --zone us-central1-b \ --tags https-tag \ --metadata startup-script="#! /bin/bash / sudo apt-get update / sudo apt-get install apache2 -y / sudo a2ensite default-ssl / sudo a2enmod ssl / sudo service apache2 restart / echo '<!doctype / /html><html><body><h1>instance-1-name</h1></body></html>’ | tee / var/www/html/index.html...