Reputation: 81
This is the screenshot of the problem
I was creating an NGINX instance and while managing the instance group, I am facing this issue. The hint in the cloud says "Please create the managed instance group with 2 NGINX web servers". Stuck up from quite some time, What should I do?
Upvotes: 7
Views: 13830
Reputation: 250
This google task is bit confusing, You don't
need to have any instances running
to complete this task, Kindly follow the below steps on a fresh space.
You can follow below steps to complete the task -
startup.sh
file, Run the command belowcat << 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
gcloud compute instance-templates create lb-backend-template --region=us-east1 --network=default --subnet=default --tags=allow-health-check --machine-type=e2-medium --image-family=debian-11 --image-project=debian-cloud --metadata-from-file startup-script=startup.sh
gcloud compute instance-groups managed create lb-server-group --base-instance-name lb-server --size 2 --template lb-backend-template --region us-east1
gcloud compute firewall-rules create lb-server-firewall --allow tcp:80 --network default ```
gcloud compute http-health-checks create http-check
gcloud compute instance-groups managed set-named-ports lb-server-group --named-ports http:80 --region us-east1
gcloud compute backend-services create lb-server-backend --protocol HTTP --http-health-checks http-check --global
gcloud compute backend-services add-backend lb-server-backend --instance-group lb-server-group --instance-group-region us-east1 --global
gcloud compute url-maps create lb-server-map --default-service lb-server-backend
gcloud compute target-http-proxies create http-lb-proxy --url-map lb-server-map
gcloud compute forwarding-rules create http-content-rule --global --target-http-proxy http-lb-proxy --ports 80
gcloud compute forwarding-rules list
NOTE :- Now wait for 5/7 minutes to see the website behind the HTTP load balancer
Lastly you can also change the names of the services as per your requirements
Upvotes: 1
Reputation: 1
To the previous comment, I would only add that there is one extra line needed -
gcloud container clusters create nucleus-jumphost-webserver1
Taken from here - https://gist.github.com/Tambunan26/9063521fdf406645aad4527ccd069149
Upvotes: 0
Reputation: 13517
You can follow below steps to complete the task -
Create startup.sh file
#! /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
gcloud compute instance-templates create web-server-template \
--metadata-from-file startup-script=startup.sh \
--network nucleus-vpc \
--machine-type g1-small \
--region us-east1
gcloud compute instance-groups managed create web-server-group \
--base-instance-name web-server \
--size 2 \
--template web-server-template \
--region us-east1
gcloud compute firewall-rules create web-server-firewall \
--allow tcp:80 \
--network nucleus-vpc
gcloud compute http-health-checks create http-basic-check
gcloud compute instance-groups managed \
set-named-ports web-server-group \
--named-ports http:80 \
--region us-east1
gcloud compute backend-services create web-server-backend \
--protocol HTTP \
--http-health-checks http-basic-check \
--global
gcloud compute backend-services add-backend web-server-backend \
--instance-group web-server-group \
--instance-group-region us-east1 \
--global
gcloud compute url-maps create web-server-map \
--default-service web-server-backend
gcloud compute target-http-proxies create http-lb-proxy \
--url-map web-server-map
gcloud compute forwarding-rules create http-content-rule \
--global \
--target-http-proxy http-lb-proxy \
--ports 80
gcloud compute forwarding-rules list
Wait for for extra 10 mins to Create the website behind the HTTP load balancer.
Upvotes: 11
Reputation: 545
You are trying to use GCP Managed Instance Groups (MIG), and for that you are required to have an Instance Template from where the MIG is going to take the information in order to deploy.
Long story short, you are defining how large you want your resources to be, but you are not specifying what those resources are.
You can follow this guide if you like but here's the short version of it:
gcloud compute instance-templates create nginx-template \
--machine-type e2-standard-4 \
--image-family debian-9 \
--image-project debian-cloud \
--boot-disk-size 250GB
Either that or the template you are using doesn't exist anymore since you are using qwiklabs and those projects get erased after a while.
Upvotes: 1