Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 94 You must be signed in to star a gist
  • Fork 47 You must be signed in to fork a gist
  • Save Tambunan26/9063521fdf406645aad4527ccd069149 to your computer and use it in GitHub Desktop.
Save Tambunan26/9063521fdf406645aad4527ccd069149 to your computer and use it in GitHub Desktop.
Task 1: Create a project jumphost instance
Navigation menu > Compute engine > VM Instance
Task 2: Create a Kubernetes service cluster
gcloud config set compute/zone us-east1-b
gcloud container clusters create nucleus-webserver1
gcloud container clusters get-credentials nucleus-webserver1
kubectl create deployment hello-app --image=gcr.io/google-samples/hello-app:2.0
kubectl expose deployment hello-app --type=LoadBalancer --port 8080
kubectl get service
Task 3: Setup an HTTP load balancer
cat << EOF > startup.sh
#! /bin/bash
apt-get update
apt-get install -y nginx
service nginx start
sed -i -- 's/nginx/Google Cloud Platform - '"\$HOSTNAME"'/' /var/www/html/index.nginx-debian.html
EOF
1 .Create an instance template :
gcloud compute instance-templates create nginx-template \
--metadata-from-file startup-script=startup.sh
2 .Create a target pool :
gcloud compute target-pools create nginx-pool
3 .Create a managed instance group :
gcloud compute instance-groups managed create nginx-group \
--base-instance-name nginx \
--size 2 \
--template nginx-template \
--target-pool nginx-pool
gcloud compute instances list
4 .Create a firewall rule to allow traffic (80/tcp) :
gcloud compute firewall-rules create www-firewall --allow tcp:80
gcloud compute forwarding-rules create nginx-lb \
--region us-east1 \
--ports=80 \
--target-pool nginx-pool
gcloud compute forwarding-rules list
5 .Create a health check :
gcloud compute http-health-checks create http-basic-check
gcloud compute instance-groups managed \
set-named-ports nginx-group \
--named-ports http:80
6 .Create a backend service and attach the manged instance group :
gcloud compute backend-services create nginx-backend \
--protocol HTTP --http-health-checks http-basic-check --global
gcloud compute backend-services add-backend nginx-backend \
--instance-group nginx-group \
--instance-group-zone us-east1-b \
--global
7 .Create a URL map and target HTTP proxy to route requests to your URL map :
gcloud compute url-maps create web-map \
--default-service nginx-backend
gcloud compute target-http-proxies create http-lb-proxy \
--url-map web-map
8 .Create a forwarding rule :
gcloud compute forwarding-rules create http-content-rule \
--global \
--target-http-proxy http-lb-proxy \
--ports 80
gcloud compute forwarding-rules list
@Shaileshchaskar81
Copy link

Im not able to create backend services it says could not fetch resourses

Can you give more details of the error and the command used.

@Krakoby
Copy link

Krakoby commented Nov 13, 2021

Error it is showing:-
Please create the managed instance group with 2 nginx web server
How to solve??

  • gcloud compute instance-groups managed set-named-ports nginx-group --named-ports http:80 is important step, this should fix the issue

Thanks, I was about to rage at Quicklabs for their buggy checker that didn't recognized them

@Shaileshchaskar81
Copy link

Error it is showing:-
Please create the managed instance group with 2 nginx web server
How to solve??

  • gcloud compute instance-groups managed set-named-ports nginx-group --named-ports http:80 is important step, this should fix the issue

Thanks, I was about to rage at Quicklabs for their buggy checker that didn't recognized them

@Krakoby - Glad it helped.

@aagirre92
Copy link

aagirre92 commented Dec 8, 2021

gcloud compute instance-groups managed set-named-ports lb-backend-group --named-ports http:80 --zone=us-east1-b did it for me (I was receiving the error "Please create the managed instance group with 2 nginx web server" even though the load balancer worked properly)

@alekssze
Copy link

alekssze commented Dec 9, 2021

The comment from SyedFahadShamim also worked for me

write "gcloud container clusters create nucleus-jumphost-webserver1" rather than "gcloud container clusters create nucleus-webserver1"

@PingNan-Chiu
Copy link

gcloud config set compute/zone us-east1-b
so
gcloud compute instance-groups managed set-named-ports nginx-group --named-ports http:80
should be
gcloud compute instance-groups managed set-named-ports nginx-group --named-ports http:80 --zone=us-east1-b

@MKP-DK
Copy link

MKP-DK commented Mar 9, 2022

"Please verify the web servers are serving on frontend of HTTP(s) Load Balancer"

For this specific error if you have steps right, I think its in the Progress checker the issue is, beside creating the FW Rule with the dynamic name generated in Description, add identically rule:

gcloud compute firewall-rules create web-server-firewall
--allow tcp:80
--network VPC_NAME

Fixed it immediatly for me, so its the name that is the issue

@juanglobo
Copy link

where can I find the VPC_NAME?

@MKP-DK
Copy link

MKP-DK commented Mar 11, 2022

where can I find the VPC_NAME?

You can see in VPC Networks in cloud console or with gcloud compute networks list

@parkerpeterex
Copy link

Last Task : gcloud compute forwarding-rules list

@warmachine028
Copy link

if anyone getting error like this:

Screenshot 2022-05-16 120014
try this:

gcloud compute target-pools create nginx-pool --region=us-east

@sksinghl498
Copy link

I am getting "It doesn't look like you've completed this step yet. Try again." waited for 15-20min. No luck. when I did curl to forwarding-rules IP Address, I am getting html page in return like _"

Welcome to Google Cloud Platform - nginx-t9h0!

If you see this page, the Google Cloud Platform - nginx-t9h0 web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to [nginx.org](http://Google Cloud Platform - nginx-t9h0.org/). Commercial support is available at [nginx.com](http://Google Cloud Platform - nginx-t9h0.com/).
Thank you for using Google Cloud Platform - nginx-t9h0.
"_ But not able to finish the challenge. it is stuck at 50 for task3. Not sure what is the issue. Any suggestion to identify the issue?

Use this code for startup.sh

cat << EOF > startup.sh #! /bin/bash apt-get update apt-get install -y nginx sed -i -- 's/nginx/Google Cloud Platform - '"$HOSTNAME"'/' /var/www/html/index.nginx-debian.html service nginx start EOF

Reason:~ in qwiklabs version of code. Server is started before modifying the file, and hence the file does not get modified and you get an error of "Please verify the web servers are serving on frontend of HTTP(s) Load Balancer"

If this helped you, connect with me on LinkedIn https://www.linkedin.com/in/viplavpandhurnekar

@sksinghl498
Copy link

thanks a lot bro .......

@Harsh1091
Copy link

Even though I finished in sequence the steps u have jot down, I am still facing the error- "Please verify the web servers are serving on frontend of HTTP(s) Load Balancer". Help, please.

Hi, I encountered the same message, I moved on to : "Task 6:Testing traffic sent to your instances", completed it and went back to "Check my progress" for "Create an HTTP load balancer" and then it worked! (Earlier on trying : "gcloud container clusters create nucleus-jumphost-webserver1", Google cloud terminated my lab quoting I wasn't following lab instructions. So I had to redo the lab)

Hi please tell me did you find solution?

@Fatim-Sohail
Copy link

It was very helpful. I tried doing this lab watching three different yt tutorials but got a lot of errors. This one worked. Great work.

@sj1705
Copy link

sj1705 commented Jun 7, 2022

thanks a lot guys

@jmfloraldephilippines
Copy link

Thank you for this @Tambunan26 . @namratajanawade thanks as well I also encounter same message after all the load balancing steps and just tested it via browser as described in Task 6.

@mufaddal-ux
Copy link

how you have resolved that error?

@mvsimplicio
Copy link

How do I rename the firewall rule on shell ?

@itsRkator
Copy link

Im not able to create backend services it says could not fetch resourses

please pass region or zone as argument then try again

@hophopsammy
Copy link

Hello guys,

I was doing this lab as well and encountered exactly the same problem list above. Waiting several minutes didn't let me escape from "Earned point: 40" load balancer error. I kept trying and even exhausted my 5 time quota for a specific lab, so I wrote to Qwiki support for help.

Basically they returned some instructions identical to this gist, but these points may help:

  1. Watch your startup.sh content.
    The system seems to check your load balancer working by visiting your frontend, cache the page they get, until they see different hostnames. So line 28 sed -i -- 's/nginx/Google Cloud Platform - '"\$HOSTNAME"'/' /var/www/html/index.nginx-debian.html is very important. Do not have an unexpected space or line break in it.
  2. Try using VPC network nucleus-vpc instead.
    The Qwiki project is provisioned with two VPC networks.
    Using default VPC network should not effect this lab practically, but I added specification --network nucleus-vpc when creating instance templates and firewall.
  3. Click Check my progress AFTER manually browsing your frontend address.
    If your load balancer works correctly, you should be able to connect to your nginx services via the IP listed on gcloud compute forwarding-rules list. Open another browser page and visit it. If you do so right after creating the forwarding rule, you should get an HTTP 404 error, which is normal. Wait and reload until it can gives you 2 versions of Nginx page WITH your backend VM hostname.

Hope you all can defeat this lab! I spent 2 nights on this.

Thanks for this @kingwilly71!

@andredeabreugoncalves
Copy link

Crie o site por trás do balanceador de carga HTTP Verifique se os servidores da Web estão servindo no frontend do balanceador de carga HTTP(s) Estou recebendo este erro, por favor, alguém o resolveu

Siga este link

https://gist.github.com/Tambunan26/9063521fdf406645aad4527ccd069149#gistcomment-3915060

Resolvi desta forma:

gcloud compute firewall-rules create grant-tcp-rule-408
--network=default
--action=allow
--direction=ingress
--source-ranges=130.211.0.0/22,35.191.0.0/16
--rules=tcp:80

@raullb34
Copy link

raullb34 commented Nov 6, 2022

Crie o site por trás do balanceador de carga HTTP Verifique se os servidores da Web estão servindo no frontend do balanceador de carga HTTP(s) Estou recebendo este erro, por favor, alguém o resolveu

Siga este link
https://gist.github.com/Tambunan26/9063521fdf406645aad4527ccd069149#gistcomment-3915060

Resolvi desta forma:

gcloud compute firewall-rules create grant-tcp-rule-408 --network=default --action=allow --direction=ingress --source-ranges=130.211.0.0/22,35.191.0.0/16 --rules=tcp:80

This command resolve the problem, many thanks

@cespirandelli
Copy link

If you are not doing it right in command line, you can see this video that shows how to run this Lab without command line. https://www.youtube.com/watch?v=zv25HHm8kmA

@kubaPod
Copy link

kubaPod commented Jan 7, 2023

If you are not doing it right in command line, you can see this video that shows how to run this Lab without command line. https://www.youtube.com/watch?v=zv25HHm8kmA

@cespirandelli some actions seem to be under the hood there, I am talking about target-pool, url map and a forwarding rule. right?

@marcodelmart
Copy link

Thanks bro! 🥇

@ankitg4
Copy link

ankitg4 commented Aug 9, 2023

I was able complete 3rd task with
cat << EOF > startup.sh
#! /bin/bash
apt-get update
apt-get install -y nginx
service nginx start
sed -i -- 's/nginx/Google Cloud Platform - '"$HOSTNAME"'/' /var/www/html/index.nginx-debian.html
service nginx start
EOF
gcloud compute instance-templates create nginx-template --metadata-from-file startup-script=startup.sh
gcloud compute target-pools create nginx-poolgcloud compute instance-groups managed create nginx-group --base-instance-name nginx --size 2 --template nginx-template --target-pool nginx-pool
gcloud compute firewall-rules create permit-tcp-rule-733 --allow tcp:80
gcloud compute forwarding-rules create nginx-lb --region us-east1 --ports=80 --target-pool nginx-pool
gcloud compute http-health-checks create http-basic-checkgcloud compute target-pools add-health-checks nginx-pool --http-health-checks http-basic-check --region us-east1
gcloud compute instance-groups managed set-named-ports nginx-group --named-ports http:80 --zone=us-east1-c
gcloud compute backend-services create nginx-backend --protocol HTTP --http-health-checks http-basic-check --global
gcloud compute backend-services add-backend nginx-backend --instance-group nginx-group --instance-group-zone us-east1-c --global
gcloud compute url-maps create web-map --default-service nginx-backend
gcloud compute target-http-proxies create http-lb-proxy --url-map web-map
gcloud compute forwarding-rules create http-content-rule --global --target-http-proxy http-lb-proxy --ports 80

@therealdhrxv
Copy link

"Please verify the web servers are serving on frontend of HTTP(s) Load Balancer"

For this specific error if you have steps right, I think its in the Progress checker the issue is, beside creating the FW Rule with the dynamic name generated in Description, add identically rule:

gcloud compute firewall-rules create web-server-firewall --allow tcp:80 --network VPC_NAME

Fixed it immediatly for me, so its the name that is the issue

thank you so much 🙏🥂

@bcastro14
Copy link

I was getting the error "Please create the managed instance group with 2 nginx web server" after doing everything, and using the command gcloud compute instance-groups managed set-named-ports YOUR_MANAGED_INSTANCE_GROUP_NAME --named-ports http:80 --zone=YOUR_ZONE solved it for me and I could get the final check in the lab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment