Configure HTTP and health check firewall rules

Підтвердити виконання

/ 40

Configure instance templates and create instance groups

Підтвердити виконання

/ 30

Configure the Internal Load Balancer

Підтвердити виконання

/ 30

This lab may incorporate AI tools to support your learning.
This content is not yet optimized for mobile devices.
For the best experience, please visit us on a desktop computer using a link sent by email.

GSP216

Google Cloud self-paced labs

Overview

Google Cloud's Internal Load Balancing (ILB) is a crucial service for managing and scaling your private application infrastructure. It enables you to distribute TCP/UDP-based traffic efficiently across internal virtual machine instances, ensuring that your applications are highly available and performant within your private network. By providing a single, stable private IP address for your services, ILB simplifies internal application communication and enhances system resilience.

In this lab, you set up an internal service by creating two managed instance groups in the same region, representing a common deployment pattern for highly available applications. Then, you configure and thoroughly test an Internal Load Balancer, using these instance groups as its backends. This setup mimics a real-world scenario where an internal application, such as a microservice, an API endpoint, or a database, needs to be accessible to other internal services or applications without exposure to the public internet.

Architecture diagram of an internal load balancer distributing traffic across two regional managed instance groups

Objectives

In this lab, you learn how to perform the following tasks:

  • Configure essential firewall rules to allow secure HTTP traffic and health checks for internal backends.
  • Design and implement instance templates for consistent and scalable VM deployments.
  • Create and manage managed instance groups for automated scaling and self-healing of your application backends.
  • Set up and test an Internal Load Balancer, demonstrating its ability to distribute internal traffic effectively and ensure service availability.

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.

This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.

How to start your lab and sign in to the Google Cloud console

  1. Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:

    • The Open Google Cloud console button
    • The temporary credentials (username and password) that you must use for this lab
    • Other information, if needed, to step through this lab

    Note that the lab timer is located near the top of the page, showing the remaining time.

  2. Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).

    The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab setup and access panel.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab setup and access panel.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field. Navigation menu icon and Search field

Task 1. Configure HTTP and health check firewall rules

Proper firewall rules are the foundation of a secure and functional internal load-balanced environment. They ensure that only authorized traffic reaches your backend services and that the load balancer can accurately assess the health of your instances.

Configure firewall rules to allow HTTP traffic to the backends and TCP traffic from the Google Cloud health checker.

Explore the my-internal-app network

The lab environment preconfigures the my-internal-app network with subnet-a and subnet-b, along with firewall rules for RDP, SSH, and ICMP traffic.

  1. In the Google Cloud console, on the Navigation menu, select VPC network > VPC networks.

  2. Scroll to view the my-internal-app network and its subnets: subnet-a and subnet-b.

    Each Google Cloud project starts with the default network. In addition, the lab environment creates the my-internal-app network shown in the network diagram.

    You create the managed instance groups in subnet-a and subnet-b. Both subnets are in the region because an Internal Load Balancer is a regional service. The managed instance groups are in different zones, making your service resilient to zonal failures.

Create the HTTP firewall rule

Create a firewall rule to allow HTTP traffic to the backends from the load balancer and the internet (to install Apache on the backends).

  1. In the VPC network navigation menu, select Firewall.

    The lab environment preconfigures the app-allow-icmp and app-allow-ssh-rdp firewall rules.

  2. Click Create firewall rule.

  3. Set the following values, and leave the remaining settings as their defaults:

    Property Value (type value or select option as specified)
    Name app-allow-http
    Network my-internal-app
    Targets Specified target tags
    Target tags lb-backend
    Source filter IPv4 ranges
    Source IPv4 ranges 10.10.0.0/16
    Protocols and ports Specified protocols and ports, select TCP, and type 80
Note: Include /16 in Source IPv4 ranges to specify all networks.
  1. Click Create.

Create the health check firewall rule

Health checks determine which instances of a load balancer can receive new connections. For internal load balancing, the health check probes to your load-balanced instances come from addresses in the ranges 130.211.0.0/22 and 35.191.0.0/16. Your firewall rules must allow these connections.

  1. On the Firewall page, click Create firewall rule.

  2. Set the following values, and leave the remaining settings as their defaults:

    Property Value (type value or select option as specified)
    Name app-allow-health-check
    Network my-internal-app
    Targets Specified target tags
    Target tags lb-backend
    Source filter IPv4 ranges
    Source IPv4 ranges 130.211.0.0/22, 35.191.0.0/16
    Protocols and ports Specified protocols and ports, and then select TCP
Note: Enter the two Source IPv4 ranges one at a time, and press SPACE between them.
  1. Click Create.

Click Check my progress to verify the objective.

Configure HTTP and health check firewall rules

Task 2. Configure instance templates and create instance groups

Instance templates and managed instance groups are the backbone of scalable, resilient, and manageable applications. They allow you to define a standard configuration for your VMs and then automatically manage their lifecycle, ensuring consistency and enabling automated scaling and self-healing.

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

Configure the instance templates

An instance template is an API resource that you can use to create VM instances and managed instance groups. Instance templates define the machine type, boot disk image, subnet, labels, and other instance properties. Create an instance template for both subnets of the my-internal-app network.

  1. In the Google Cloud console, on the Navigation menu, select Compute Engine > Instance templates.

  2. Click Create instance template.

  3. For Name, type instance-template-1

  4. For Location, select Global.

  5. For Series, select E2.

  6. For Machine type, select Shared-core > e2-micro.

  7. Click Advanced options.

  8. Click Networking.

  9. For Network tags, type lb-backend

    Note: The network tag lb-backend ensures that the HTTP and health check firewall rules apply to these instances.
  10. For Network interfaces, click the drop-down icon to edit.

  11. Set the following values, and leave the remaining settings as their defaults:

    Property Value (type value or select option as specified)
    Network my-internal-app
    Subnetwork subnet-a
    External IPv4 address None
  12. Click Done.

  13. Click Management.

  14. In the Automation > Startup script field, paste the following script:

    #!/bin/bash apt-get update apt-get install -y apache2 php libapache2-mod-php cat <<'EOF' > /var/www/html/index.php <h1>Internal Load Balancing Lab</h1> <h2>Client IP</h2> Your IP address : <?php echo $_SERVER['REMOTE_ADDR']; ?> <h2>Hostname</h2> Server Hostname: <?php echo gethostname(); ?> <h2>Server Location</h2> Region and Zone: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://metadata.google.internal/computeMetadata/v1/instance/zone"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Metadata-Flavor: Google')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $zone = curl_exec($ch); $parts = explode('/', $zone); echo end($parts); ?> EOF rm -f /var/www/html/index.html systemctl restart apache2
Note: This script installs Apache and PHP, and creates a page that dynamically displays the client IP and server metadata. This replaces the need for the external script file.
  1. Click Create.

Wait until Compute Engine creates the instance template.

Configure the next instance template

Create another instance template for subnet-b by copying instance-template-1. This demonstrates how easy it is to replicate configurations across different subnets or zones for high availability and disaster recovery strategies.

  1. On the Instance templates page, select the checkbox next to instance-template-1.
  2. Click Copy.
  3. For Name, type instance-template-2
  4. Click Advanced options.
  5. Click Networking.
  6. For Network interfaces, click the drop-down icon to edit.
  7. For Subnetwork, select subnet-b.
  8. Click Done.
  9. Click Create.

Create the managed instance groups

Managed instance groups (MIGs) are key to robust, self-healing, and dynamically scaling applications. They automatically replace unhealthy instances and can scale your application capacity based on demand, ensuring that your services remain available and performant without constant manual intervention. This is crucial for handling variable loads and maintaining Service Level Objectives (SLOs).

Configure one managed instance group in subnet-a and one in subnet-b.

Note: Identify another zone in the same region as subnet-a. For example, if subnet-a uses us-west2-a, you can select us-west2-b for subnet-b.
  1. In the Compute Engine navigation menu, select Instance groups.

  2. Click Create instance group.

  3. Set the following values, and leave the remaining settings as their defaults:

    Property Value (type value or select option as specified)
    Name instance-group-1
    Instance template instance-template-1
    Location Single-zone
    Region
    Zone
    Autoscaling > Minimum number of instances 1
    Autoscaling > Maximum number of instances 1
    Autoscaling > Autoscaling signals (click the drop-down icon to edit) > Signal type CPU utilization
    Target CPU utilization 80
    Initialization period 45
Note: Autoscaling is a critical feature of managed instance groups that dynamically scales resources based on measured load. This capability lets your application smoothly handle variable traffic and optimizes cloud spend.
  1. Click Create.

Repeat the procedure to create instance-group-2 in a different zone in the same region as subnet-a:

  1. Click Create instance group.

  2. Set the following values, and leave the remaining settings as their defaults:

    Property Value (type value or select option as specified)
    Name instance-group-2
    Instance template instance-template-2
    Location Single-zone
    Region
    Zone A different zone in the same region as subnet-a
    Autoscaling > Minimum number of instances 1
    Autoscaling > Maximum number of instances 1
    Autoscaling > Autoscaling signals (click the drop-down icon to edit) > Signal type CPU utilization
    Target CPU utilization 80
    Initialization period 45
  3. Click Create.

Verify the backends

Verify that Compute Engine creates VM instances in both subnets, and create a utility VM to access the backends' HTTP sites directly. This step confirms individual backend functionality before introducing the load balancer, ensuring proper setup of your service tier.

  1. In the Compute Engine navigation menu, select VM instances.

    Verify that two instances starting with instance-group-1 and instance-group-2 appear. These instances are in separate zones, and their internal IP addresses are part of the subnet-a and subnet-b CIDR blocks.

  2. To create a new instance, click Create instance.

  3. Under Machine configuration, set the following values, and leave the remaining settings as their defaults:

    Property Value (type value or select option as specified)
    Name utility-vm
    Region
    Zone
    Series E2
    Machine type e2-micro (1 shared vCPU)
  4. Click Networking.

  5. For Network interfaces, click the toggle icon to edit the network interface, and set the following values:

    Property Value (type value or select option as specified)
    Network my-internal-app
    Subnetwork subnet-a
    Primary internal IPv4 address Ephemeral (Custom)
    Custom ephemeral IP address 10.10.20.50
  6. Click Done.

  7. Click Create.

Click Check my progress to verify the objective.

Configure instance templates and create instance groups

The internal IP addresses for the backends are 10.10.20.2 and 10.10.30.2.

Note: If these IP addresses differ in your environment, replace them in the following two curl commands.
  1. For utility-vm, click SSH to open a terminal and connect.
  2. To verify the welcome page for instance-group-1-xxxx, run the following command:
curl 10.10.20.2

The output should resemble the following:

<h1>Internal Load Balancing Lab</h1><h2>Client IP</h2>Your IP address : 10.10.20.50<h2>Hostname</h2>Server Hostname: instance-group-1-1zn8<h2>Server Location</h2>Region and Zone: us-central1-a
  1. To verify the welcome page for instance-group-2-xxxx, run the following command:
curl 10.10.30.2

The output should resemble the following:

<h1>Internal Load Balancing Lab</h1><h2>Client IP</h2>Your IP address : 10.10.20.50<h2>Hostname</h2>Server Hostname: instance-group-2-q5wp<h2>Server Location</h2>Region and Zone: us-central1-b

Note: The curl commands demonstrate that each VM instance lists the Client IP and its own name and location. This is useful when you verify that the Internal Load Balancer sends traffic to both backends.
  1. To close the SSH terminal for utility-vm, run the following command:
exit

Task 3. Configure the Internal Load Balancer

Configuring the ILB centralizes access to your backend services, provides a single point of entry for internal traffic, and ensures intelligent traffic distribution based on the health and capacity of your instances. This step is crucial for achieving the high availability and scalability benefits discussed earlier, acting as a centralized access point for your distributed service.

Configure the Internal Load Balancer to balance traffic between the two backends (instance-group-1 and instance-group-2), as illustrated in this diagram:

Network diagram showing the Internal Load Balancer balancing traffic between the two backends

Start the configuration

  1. In the Google Cloud console, on the Navigation menu, select View all products.
  2. Under Networking, select Network services > Load balancing.
  3. Click Create load balancer.
  4. For Type of load balancer, select Network Load Balancer (TCP/UDP/SSL).
  5. For Proxy or passthrough, select Passthrough load balancer.
  6. For Public facing or internal, select Internal.
  7. Click Configure.
  8. For Name, type my-ilb
  9. For Region, select .
  10. For Network, select my-internal-app.

Configure the regional backend service

The backend service is the intelligence behind the ILB, defining how the load balancer distributes traffic and monitors instance health. It's essential for ensuring that traffic flows only to operational instances and preventing overload. This is also where you configure advanced features like session affinity to keep a user's connection on the same backend, or connection draining for graceful backend updates.

The backend service monitors instance groups and prevents them from exceeding configured usage.

  1. Click Backend configuration.

  2. Set the following value, and leave the remaining settings as their defaults:

    Property Value (select option as specified)
    Instance group instance-group-1
  3. Click Add a backend.

  4. For Instance group, select instance-group-2.

  5. For Health check, select Create a health check.

  6. Set the following values, and leave the remaining settings as their defaults:

    Property Value (select option as specified)
    Name my-ilb-health-check
    Protocol TCP
    Port 80
Note: Health checks determine which instances can receive new connections. This TCP health check polls instances every 5 seconds, waits up to 5 seconds for a response, and treats 2 successful or 2 failed attempts as healthy or unhealthy, respectively. This continuous monitoring is vital for quick recovery from instance failures and maintaining your Service Level Agreements (SLAs).
  1. Click Create.

Verify that a check mark appears next to Backend configuration in the Google Cloud console. If not, confirm that you completed all the previous steps.

Configure the frontend

The frontend is the exposed interface of your ILB. By assigning a static internal IP address, you provide a consistent and predictable endpoint for other internal services to connect to, simplifying your application architecture, enabling easy service discovery within your VPC, and improving reliability.

The frontend forwards traffic to the backend.

  1. Click Frontend configuration.

  2. Set the following values, and leave the remaining settings as their defaults:

    Property Value (type value or select option as specified)
    Subnetwork subnet-b
    Internal IP Under IP address, select Create IP address
  3. Set the following values, and leave the remaining settings as their defaults:

    Property Value (type value or select option as specified)
    Name my-ilb-ip
    Static IP address Let me choose
    Custom IP address 10.10.30.5
  4. Click Reserve.

  5. For Port number, type 80

  6. Click Done.

Review and create the Internal Load Balancer

  1. Click Review and finalize.
  2. Review the Backend and Frontend configurations.
  3. Click Create.

Wait until Google Cloud creates the load balancer before moving to the next task.

Click Check my progress to verify the objective.

Configure the Internal Load Balancer

Task 4. Test the Internal Load Balancer

The final test validates that the ILB distributes traffic across healthy backend instances. This confirms that your internal services are now more resilient and scalable, using the core benefits of the ILB, and that private connectivity works properly.

Verify that the my-ilb IP address forwards traffic to instance-group-1 and instance-group-2.

Access the Internal Load Balancer

  1. In the Google Cloud console, on the Navigation menu, select Compute Engine > VM instances.
  2. For utility-vm, click SSH to open a terminal and connect.
  3. To verify that the Internal Load Balancer forwards traffic, run the following command:
curl 10.10.30.5

The output should resemble the following:

<h1>Internal Load Balancing Lab</h1><h2>Client IP</h2>Your IP address : 10.10.20.50<h2>Hostname</h2>Server Hostname: instance-group-1-1zn8<h2>Server Location</h2>Region and Zone: us-central1-a Note: As expected, the Internal Load Balancer (10.10.30.5) forwards traffic to the backend.
  1. Run the same command several more times.

In the output, you see responses from instance-group-1 in and instance-group-2 in a different zone in the same region. The load balancer distributes traffic across the backend instances, proving its efficacy in ensuring high availability and distributing load.

Congratulations!

You have successfully configured and tested an Internal Load Balancer, understanding its critical role in building robust, scalable, and secure internal applications on Google Cloud.

Next steps / Learn more

For information on the basic concepts of load balancing, see the Google Cloud Load Balancing documentation.

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated November 16, 2026

Lab Last Tested May 11, 2026

Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

This content is not currently available

We can notify you via email when it becomes available

Great!

We can contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Using an Incognito or private browser window is the best way to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.