I used those command line but the backend service still unhealthy
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
gcloud compute instance-templates create nucleus-webserver-template \
--machine-type=e2-medium \
--metadata=startup-script='#! /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' \
--image-family=debian-11 \
--image-project=debian-cloud \
--tags=http-server
gcloud compute instance-groups managed create nucleus-webserver-group \
--base-instance-name=nucleus-webserver \
--template=nucleus-webserver-template \
--size=2 \
--zone=us-central1-b
gcloud compute firewall-rules create accept-tcp-rule-261 \
--allow=tcp:80 \
--target-tags=http-server \
--description="Allow port 80 traffic"
gcloud compute health-checks create http http-basic-check \
--port 80
gcloud compute backend-services create nucleus-backend-service \
--protocol=HTTP \
--health-checks=http-basic-check \
--port-name=http \
--global
gcloud compute backend-services add-backend nucleus-backend-service \
--instance-group=nucleus-webserver-group \
--instance-group-zone=us-central1-b \
--global
gcloud compute url-maps create nucleus-url-map \
--default-service=nucleus-backend-service
gcloud compute target-http-proxies create nucleus-http-proxy \
--url-map=nucleus-url-map
gcloud compute forwarding-rules create http-content-rule \
--global \
--target-http-proxy=nucleus-http-proxy \
--ports=80
gcloud compute forwarding-rules list --global
but I didn't get the score and get this message
Please create the managed instance group with 2 nginx web-server.
Hi @reham_ashraf104,
Did you check that the command executed to create the managed instance group was successful and in the correct region?
I am sharing with you the steps I followed in my Lab:
User | Count |
---|---|
18 | |
11 | |
10 | |
3 | |
2 |