0% found this document useful (0 votes)
35 views2 pages

Challenge 5

Uploaded by

High Stuff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

Challenge 5

Uploaded by

High Stuff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

et environment variables

ZONE=us-central1-c
REGION=us-central1
FIREWALL="grant-tcp-rule-319"
INSTANCE=nucleus-jumphost-790
PORT_NO=80

Task 1: Create a project jumphost instance


gcloud compute instances create $INSTANCE \
--zone=$ZONE \
--machine-type=e2-micro

Task 3: Create instance template with e2-medium


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 web-server-template \


--metadata-from-file startup-script=startup.sh \
--machine-type e2-medium \
--region $REGION

Task 4: Create the managed instance group based on the template


gcloud compute instance-groups managed create web-server-group \
--base-instance-name web-server \
--size 2 \
--template web-server-template \
--region $REGION

Task 5: Create firewall rule to allow traffic (80/tcp)


gcloud compute firewall-rules create $FIREWALL \
--allow tcp:80

Task 6: Create health check


gcloud compute http-health-checks create http-basic-check
[10:44 AM]
Task 7: Assign named ports for instance group
gcloud compute instance-groups managed set-named-ports web-server-group \
--named-ports http:80 \
--region $REGION

Task 8: Create backend service and add the instance group


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 $REGION \
--global

Task 9: Create URL map


gcloud compute url-maps create web-server-map \
--default-service web-server-backend

Task 10: Create target HTTP proxy


gcloud compute target-http-proxies create http-lb-proxy \
--url-map web-server-map

Task 11: Create forwarding rule to route HTTP traffic


gcloud compute forwarding-rules create http-forwarding-rule \
--global \
--target-http-proxy=http-lb-proxy \
--ports=80

Verify forwarding rules


gcloud compute forwarding-rules list

You might also like