Create and Manage Cloud Resources: Challenge Lab – SOLUTION

Δημοσιεύθηκε 07/11/2021

Create and Manage Cloud Resources Challenge Lab

Earned Nov 6, 2021


Navigation menu -> Compute engine -> VM Instance

  • Instance name: [Instance name]
  • Region and Zone: as it is [default vaules]
  • Series: N1
  • Machine type: f1-micro


gcloud config set compute/zone us-east1-b

gcloud container clusters create nucleus-jumphost-webserver1

gcloud container clusters get-credentials nucleus-jumphost-webserver1

kubectl create deployment hello-app

kubectl expose deployment hello-app --type=LoadBalancer --port 8082          USE GIVEN PORT

kubectl get service


cat << EOF >
#! /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

Create an instance template

gcloud compute instance-templates create nginx-template \

Create a target pool

gcloud compute target-pools create nginx-pool

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

Create a firewall rule named as allow-tcp-rule-980 to allow traffic (80/tcp)

gcloud compute firewall-rules create allow-tcp-rule-980 --allow tcp:80 

gcloud compute forwarding-rules create nginx-lb \
--region us-east1 \
--ports=80 \
--target-pool nginx-pool

gcloud compute forwarding-rules list

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

Create a backend service, and attach the managed 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 \

Create a URL map, and target the 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

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

After last command we have to wait for 3-4 minutes and then submit [Check my progress]