I ma trying 2 months ago to get this challenge lab without succes. I need help please:
This is my code, but it doesnt work
:
- Reserve a global external IP for the Load Balancer, a static IP: (THIS WORKS)
gcloud compute addresses create lb-ipv4-1
–ip-version=IPV4
–global
- Create the global Health Check: (THIS WORKS)
gcloud compute health-checks create http http-basic-check
–port 80
- CREATE FIREWALL RULES (THIS WORKS)
Step 6.1: Create the firewall rule to allow health checks:
gcloud compute firewall-rules create fw-allow-health-check
–direction=INGRESS
–priority=1000
–network=default
–action=ALLOW
–rules=tcp:80
–source-ranges=130.211.0.0/22,35.191.0.0/16 \
–target-tags=allow-health-check
- STEP: INSTANCE TEMPLATE AND INSTANCE GROUP
7.1: Create the instance Template (lb-backend-template) (THIS ONE DOES NOT WORK):
gcloud compute instance-templates create lb-backend-template\
–machine-type=e2-medium \
–tags=allow-health-check \
–image-family=debian-11 \
–image-project=debian-cloud \
–metadata=startup-script=‘#!/bin/bash
apt-get update
apt-get install -y apache2
hostname=$(hostname)
echo “Backend Server: $hostname” > /var/www/html/index.html’
- Step 2: Create the Managed Instance Group (lb-backend-group): (THIS IS NOT SERVES)
gcloud compute instance-groups managed create lb-backend-group \
–base-instance-name=lb-backend \
–size=2 \
–template=lb-backend-template\
–zone=us-east1-d
- Create the Backend service (THIS IS NOT WORKING)
gcloud compute backend-services create web-backend-service \
–protocol=HTTP \
–health-checks=http-basic-check \
–global
Step 9. Add the MIG (Managed Instance Group) to the Backend Service (THIS DOES NOT WORK)
gcloud compute backend-services add-backend web-backend-service \
–instance-group=lb-backend-group \
–instance-group-zone=us-east1-d \
–global
- Create the URL map: (THIS IS NOT WORKING)
gcloud compute url-maps create web-map-http \
–default-service=web-backend-service
- Create the HTTP proxy: (THIS DOES NOT WORK)
gcloud compute target-http-proxies create http-lb-proxy \
–url-map=web-map-http
- Create the forwarding rule: (THIS ONE DOES NOT WORK)
gcloud compute forwarding-rules create http-content-rule \
–global \
–target-http-proxy=http-lb-proxy \
–ports=80