GSP313/Challenge Lab – Create and Manage Cloud Resources: Challenge Lab

This challenge lab tests your skills and knowledge from the labs in the Create and Manage Cloud Resources quest. You should be familiar with the content of the labs before attempting this lab.

Lab Name: Create and Manage Cloud Resources: Challenge Lab (GSP313)

Task 1. Create a project jump host instance

You will use this instance to perform maintenance for the project.

Requirements:

  • Name the instance Instance name .
  • Use an f1-micro machine type.
  • Use the default image type (Debian Linux).

The command for Task 1- Change the name of the instance

gcloud compute instances create nucleus-jumphost \
          --network nucleus-vpc \
          --zone us-east1-b  \
          --machine-type f1-micro  \
          --image-family debian-9  \
          --image-project debian-cloud \
          --scopes cloud-platform \
          --no-address

Task 2. Create a Kubernetes service cluster

The team is building an application that will use a service running on Kubernetes. You need to:

  • Create a cluster (in the us-east1-b zone) to host the service.
  • Use the Docker container hello-app (gcr.io/google-samples/hello-app:2.0) as a placeholder; the team will replace the container with their own work later.
  • Expose the app to port App port number .

The command for Task 2: Change the port Number

gcloud container clusters create nucleus-backend \
          --num-nodes 1 \
          --network nucleus-vpc \
          --region us-east1
gcloud container clusters get-credentials nucleus-backend \
          --region us-east1

kubectl create deployment hello-server \
          --image=gcr.io/google-samples/hello-app:2.0

kubectl expose deployment hello-server \
          --type=LoadBalancer \
          --port 8080

Task 3. Set up an HTTP load balancer

You will serve the site via nginx web servers, but you want to ensure that the environment is fault-tolerant. Create an HTTP load balancer with a managed instance group of 2 nginx web servers. Use the following code to configure the web servers; the team will replace this with their own configuration later.

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

You need to:

  • Create an instance template.
  • Create a target pool.
  • Create a managed instance group.
  • Create a firewall rule named as Firewall rule to allow traffic (80/tcp).
  • Create a health check.
  • Create a backend service, and attach the managed instance group with named port (http:80).
  • Create a URL map, and target the HTTP proxy to route requests to your URL map.
  • Create a forwarding rule.

The command for Task 2: Change the Firewall rule

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
Congratulations: You are done.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *