Arcade Simulator: DevOps Engineer
Solution for Arcade Simulator: DevOps Engineer. 1 lab: GSP216. Fast copy-paste commands for Google Cloud.
GSP216 — Enhance Application Reliability and Scalability with Internal Load Balancing
Estimated time: 15 minutes
# 🚀 Enhance Application Reliability and Scalability with Internal Load Balancing > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created for educational purposes, hands-on practice, and Google Cloud certification preparation. This guide is designed to help learners understand Google Cloud services and complete practical exercises. Always attempt the lab yourself first and follow Google Cloud Skills Boost / Qwiklabs Terms of Service. This walkthrough is not affiliated wi
clear
CYAN='\e[1;36m'
BLUE='\e[1;34m'
RESET='\e[0m'
BOLD='\e[1m'
GREEN='\e[1;32m'
YELLOW='\e[1;33m'
MAGENTA='\e[1;35m'
echo -e "${CYAN}${BOLD}"
echo " ____ _ _ _ __ ___ "
echo " / __ \ | | (_) | / _| / _ \ "
echo " | | | |_ __| |__ _| |_ ___ | |_ | | | |_ __ ___ "
echo " | | | | '__| '_ \| | __| / _ \ | _|| | | | '_ \/ __| "
echo " | |__| | | | |_) | | |_ | (_) | | | | |_| | |_) \__ \ "
echo " \____/|_| |_.__/|_|\__| \___/ |_| \___/| .__/|___/ "
echo " | | "
echo " |_| "
echo -e "${RESET}"
echo -e "${MAGENTA}${BOLD}Please check your lab instructions panel for your assigned Region and Zone.${RESET}"
read -p "Enter your Region (e.g., us-central1): " REGION
read -p "Enter your Primary Zone (e.g., us-central1-b): " ZONE_1
echo ""
echo -e "${CYAN}Task 1: Creating HTTP and Health Check Firewall Rules...${RESET}"
gcloud compute firewall-rules create app-allow-http --network=my-internal-app --action=ALLOW --direction=INGRESS --target-tags=lb-backend --source-ranges=10.10.0.0/16 --rules=tcp:80 --quiet >/dev/null 2>&1
gcloud compute firewall-rules create app-allow-health-check --network=my-internal-app --action=ALLOW --direction=INGRESS --target-tags=lb-backend --source-ranges=130.211.0.0/22,35.191.0.0/16 --rules=tcp --quiet >/dev/null 2>&1
echo -e "\n${GREEN}✅ Task 1 Complete! Click 'Check my progress' on the first task and proceed to the Manual UI Steps below.${RESET}"CYAN='\e[1;36m'
BLUE='\e[1;34m'
RESET='\e[0m'
BOLD='\e[1m'
GREEN='\e[1;32m'
YELLOW='\e[1;33m'
echo -e "${BLUE}${BOLD}╔════════════════════════════════════════════════════════════╗${RESET}"
echo -e "${BLUE}${BOLD}║ 🚀 COMMAND 2: INTERNAL LOAD BALANCER & TESTING ║${RESET}"
echo -e "${BLUE}${BOLD}╚════════════════════════════════════════════════════════════╝${RESET}\n"
echo -e "${YELLOW}Syncing zones from your manual UI deployment...${RESET}"
export REGION=$(gcloud compute networks subnets list --network=my-internal-app --filter="name=subnet-a" --format="value(region)" | head -n 1)
export ZONE_1=$(gcloud compute instance-groups managed list --filter="name=instance-group-1" --format="value(zone)" | awk -F/ '{print $NF}')
export ZONE_2=$(gcloud compute instance-groups managed list --filter="name=instance-group-2" --format="value(zone)" | awk -F/ '{print $NF}')
echo -e "${CYAN}Task 3a: Creating Regional Health Check...${RESET}"
gcloud compute health-checks create tcp my-ilb-health-check --region=$REGION --port=80 --quiet >/dev/null 2>&1
echo -e "${CYAN}Task 3b: Creating Internal Backend Service...${RESET}"
gcloud compute backend-services create my-ilb --load-balancing-scheme=internal --protocol=tcp --region=$REGION --network=my-internal-app --health-checks=my-ilb-health-check --health-checks-region=$REGION --quiet >/dev/null 2>&1
echo -e "${CYAN}Task 3c: Attaching Instance Groups to Backend...${RESET}"
gcloud compute backend-services add-backend my-ilb --region=$REGION --instance-group=instance-group-1 --instance-group-zone=$ZONE_1 --quiet >/dev/null 2>&1
gcloud compute backend-services add-backend my-ilb --region=$REGION --instance-group=instance-group-2 --instance-group-zone=$ZONE_2 --quiet >/dev/null 2>&1
echo -e "${CYAN}Task 3d: Reserving Static Internal IP (10.10.30.5)...${RESET}"
gcloud compute addresses create my-ilb-ip --region=$REGION --subnet=subnet-b --addresses=10.10.30.5 --quiet >/dev/null 2>&1
echo -e "${CYAN}Task 3e: Creating Forwarding Rule (Frontend)...${RESET}"
gcloud compute forwarding-rules create my-ilb --region=$REGION --load-balancing-scheme=internal --network=my-internal-app --subnet=subnet-b --address=my-ilb-ip --ip-protocol=TCP --ports=80 --backend-service=my-ilb --backend-service-region=$REGION --quiet >/dev/null 2>&1
echo -e "${YELLOW}Waiting 20 seconds for the Internal Load Balancer to propagate...${RESET}"
sleep 20
echo -e "${CYAN}Task 4: Testing Load Balancer connection from Utility VM...${RESET}"
gcloud compute ssh utility-vm --zone=$ZONE_1 --quiet --command="curl -s 10.10.30.5"
echo ""
echo -e "${GREEN}${BOLD}# ─────────────────────────────────────────────────────────────${RESET}"
echo -e "${GREEN}${BOLD}# Lab cleared? Like the video and subscribe to Orbit of Ops 🚀${RESET}"
echo -e "${GREEN}${BOLD}# youtube.com/@orbitofops${RESET}"
echo -e "${GREEN}${BOLD}# ─────────────────────────────────────────────────────────────${RESET}"