Networking in GCP - Hands-On Lab
Case Study: Designing a simple web service with regional subnets and load balancing.
Hands-on Lab: Create a VPC, configure subnets, and deploy a load balancer.
Lab Objective:
Students will create a Virtual Private Cloud (VPC), set up subnets, deploy virtual machines (VMs), configure firewall rules, and set up a load balancer for distributing traffic to backend VMs.
Step-by-Step Lab:
1. Create a Virtual Private Cloud (VPC)
Step 1.1: Log into the Google Cloud Console.
Step 1.2: Navigate to the VPC network section by searching for “VPC
network” in the search bar.
Step 1.3: Click on Create VPC network.
Step 1.4: Name the VPC (e.g., my-first-vpc), choose Custom mode, and proceed to configure subnets.
2. Configure Subnets
Step 2.1: Add the first subnet in the US region (e.g., us-central1).
Subnet name: us-central-subnet
Region: us-central1
IP range: 10.0.0.0/24
Step 2.2: Add a second subnet in another region (e.g., europe-west1).
Subnet name: europe-west-subnet
Region: europe-west1
IP range: 10.1.0.0/24
Step 2.3: Click Create to finalize the VPC and subnets.
3. Create Virtual Machines (VMs)
Step 3.1: Go to the Compute Engine section and click Create VM instance.
Step 3.2: Name the instance us-vm.
Region: us-central1
Subnet: us-central-subnet
Machine type: e2-medium
Boot disk: Ubuntu or Debian
Network tags: frontend
Step 3.3: Create another VM in the europe-west1 region:
Name: europe-vm
Subnet: europe-west-subnet
Follow the same settings as the US instance.
4. Configure Firewall Rules
Step 4.1: Navigate to VPC network > Firewall and click Create firewall rule.
Step 4.2: Set the following parameters:
• Name: allow-ssh
• Targets: All instances in the network
• Source IP ranges: 0.0.0.0/0
• Protocols and ports: Check TCP and specify port 22 for SSH.
• Tags: Apply this rule to VMs with the frontend tag.
Step 4.3: Create another rule to allow HTTP traffic:
• Name: allow-http
• Source IP: 0.0.0.0/0
• Protocols: TCP 80
• Apply the rule to VMs tagged with frontend.
5. Set Up a Load Balancer
Step 5.1: Go to Network Services > Load balancing and click Create load
Balancer.
Step 5.2: Choose HTTP(S) Load Balancer and select Global.
Step 5.3: Name the load balancer (e.g., my-lb).
Step 5.4: Configure the backend service:
Add the two VM instances (us-vm and europe-vm) as backend instances.
Configure the health check (default TCP on port 80).
Step 5.5: Set up the frontend:
Choose a public IP.
Protocol: HTTP
Port: 80
Step 5.6: Click Create and verify the load balancer works by accessing the public IP in your browser.
Lab Wrap-Up
• Goal: Students should have deployed a globally distributed VPC with subnets in different regions, created firewall rules, and deployed a load balancer to serve traffic across multiple regions.
• Deliverables: Students should capture screenshots of the running VMs, the load balancer’s configuration, and the website running on the public IP.
No comments:
Post a Comment