Challenge 1: Create Managed Instance Groups

Next Challenge

Introduction

A managed instance group uses an instance template to create a group of identical instances. Use these to create the backend of the HTTP Load Balancer.

Description

Create Instance Template

We need to create an instance template that will be using with a load balancer in the next challenge.

Keep the following things in mind:

  • Choose something reasonable for the VM series such as N1
  • Keep note of the subnet you use for networking and make sure everything you create in this gHack uses the same subnet
  • Add a network tag: allow-health-check

    Note The network tag allow-health-check ensures that the HTTP Health Check and SSH firewall rules apply to these instances.

    Note Make sure to type a space or press tab after typing the tag name, otherwise it might not get set.

  • We need to use a start up script to install some things on a new VM. Paste this code into the Startup Script field:

      #! /bin/bash
      sudo apt-get update
      sudo apt-get install apache2 unzip -y
      sudo a2ensite default-ssl
      sudo a2enmod ssl
      export vm_hostname="$(hostname)"
      sudo echo "Page served from: $vm_hostname" | \
      sudo tee /var/www/html/index.html
    

Create Managed Instance Group

Now that we have an instance template we can create an instance group that uses it. An instance group is just a grouping of virtual machines. In this case we’re specifying that they should all be created from the same template.

Keep the following things in mind:

  • Your managed instance group needs to be stateless
  • It should be Single zone and in the same region you’ve been using up to now
  • Keep the instances to 1
  • Set port 80 as a “named port” port. This allows the load balancing service to forward traffic to the named port.

Success Criteria

  • You’ve created an instance template which defines instance properties including type, boot disk image, and subnet
  • Your instance template is configured to allow health checks
  • You’ve created a new managed instance group as the HTTP backend
  • A port is configured to allow the load balancing service to forward traffic to the backend

Learning Resources

Next Challenge