Task 5: Create an HTTP load balancer
HTTP(S) Load Balancing is implemented on Google Front End (GFE). GFEs are distributed globally and operate together using Google's global network and control plane. You can configure URL rules to route some URLs to one set of instances and route other URLs to other instances. Requests are always routed to the instance group that is closest to the user, if that group has enough capacity and is appropriate for the request. If the closest group does not have enough capacity, the request is sent to the closest group that does have capacity.
To set up a load balancer with a Compute Engine backend, your VMs need to be in an instance group. The managed instance group provides VMs running the backend servers of an external HTTP load balancer. For this lab, backends serve their own hostnames.
- First, create the load balancer template:
- Create a managed instance group based on the template:
- Create the fw-allow-health-check firewall rule. This is an ingress rule that allows traffic from the Google Cloud health checking systems (130.211.0.0/22 and 35.191.0.0/16). This lab uses the target tag allow-health-check to identify the VMs.
- Now that the instances are up and running, set up a global static external IP address that your customers use to reach your load balancer.
Note the IPv4 address that was reserved:
- Create a healthcheck for the load balancer:
- Create a backend service:
- Add your instance group as the backend to the backend service:
- Create a URL map to route the incoming requests to the default backend service:
- Create a target HTTP proxy to route requests to your URL map:
- Create a global forwarding rule to route incoming requests to the proxy: