Getting Started: Create and Manage Cloud Resources: Challenge Lab Tutorial
Detailed walkthrough of the Create & Manage Cloud Resources Skill Badge on Google Cloud Platform
This medium article focuses on the detailed walk through of the steps I took to solve the challenge lab of the Create and Manage Cloud Resources Skill Badge on the Google Cloud Platform. I got access to this lab in the 30 Days of Google Cloud Program held in October 2020. Thanks to Google!
This lab is only recommended for students who have completed the labs in the Getting Started: Create and Manage Cloud Resources Quest. Are you up for the challenge?
Challenge Scenario
There are three tasks in this challenge lab, all of which should be completed to score 100/100 points and acquire the respective skill badge. This tutorial list out the steps I took to solve all the three challenges within the lab. The three tasks are as follows:
- Creating a Project Jumphost instance.
- Creating a Kubernetes Service Cluster.
- Creating the Web Server Frontend.
Important Note
Before starting this lab, ensure that you do whatever is required. Allocating more resources or doing something that is not required may lead to blocking of account by qwiklabs admin. Doing something other than that required in the lab results in account blocked by qwiklabs. Don’t worry. I came across this problem. The account can easily be unblocked by contacting qwiklabs support within a second.
Detailed Tutorial of Task — 1
In task 1, it requires the user to create a Jumphost instance with the following parameters:
- Naming of the instance should be nucleus-jumphost
- The machine type should be f1-micro.
- Using the default image type (Debian Linux).
Go to navigation menu > Compute Engine > VM Instance.
Select the above parameters and click create.
Wait for a second and then check your progress in the lab. You should see a green mark. Now lets go to task-2.
Detailed Tutorial of Task — 2
In task 2, the lab requires the user to create a Kubernetes Service Cluster with the following parameters:
- Creating the cluster in the us-east1 region.
- Using the Docker container hello-app (`gcr.io/google-samples/hello-app:2.0`) as a place holder.
- Exposing the app on port 8080.
Open the Cloud Shell and wait for it to be configured. Then run the following set of commands to create a kubernetes cluster.
gcloud config set compute/zone us-east1-bgcloud container clusters create nucleus-jumphost-webserver1gcloud container clusters get-credentials nucleus-jumphost-webserver1kubectl create deployment hello-app --image=gcr.io/google-samples/hello-app:2.0kubectl expose deployment hello-app --type=LoadBalancer --port 8080kubectl get service
The deployment takes time. You can check by running kubectl get service again to see if you get the green mark in the lab home page!
Detailed Tutorial of Task — 3
Step 3 requires to setup an HTTP Load Balancer with a managed instance group of two nginx web servers. We need to do a set of 8 small tasks in order to score full in this task. The following set of configurations is given in advance:
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
Copy and paste the above command in the cloud shell and execute it. After that, follow the below steps:
- Creating an instance template:
gcloud compute instance-templates create nginx-template \
--metadata-from-file startup-script=startup.sh
2. Creating a target pool:
gcloud compute target-pools create nginx-pool
This command will ask you the location where you want to create the target pool. If it’s not us-east1, type “n”.
Select the number corresponding to us-east1 in the list. In my case it was 18. Type 18 and hit Enter.
3. Creating a managed instance group:
gcloud compute instance-groups managed create nginx-group \
--base-instance-name nginx \
--size 2 \
--template nginx-template \
--target-pool nginx-poolgcloud compute instances list
4. Creating a firewall rule to allow traffic (80/tcp):
gcloud compute firewall-rules create www-firewall --allow tcp:80gcloud compute forwarding-rules create nginx-lb \
--region us-east1 \
--ports=80 \
--target-pool nginx-poolgcloud compute forwarding-rules list
5. Creating a health check:
gcloud compute http-health-checks create http-basic-checkgcloud compute instance-groups managed \
set-named-ports nginx-group \
--named-ports http:80
6. Creating a backend service and attach the manged instance group:
gcloud compute backend-services create nginx-backend \
--protocol HTTP --http-health-checks http-basic-check --globalgcloud compute backend-services add-backend nginx-backend \
--instance-group nginx-group \
--instance-group-zone us-east1-b \
--global
7. Creating a URL map and target HTTP proxy to route requests to your URL map:
gcloud compute url-maps create web-map \
--default-service nginx-backendgcloud compute target-http-proxies create http-lb-proxy \
--url-map web-map
8. Creating a forwarding rule:
gcloud compute forwarding-rules create http-content-rule \
--global \
--target-http-proxy http-lb-proxy \
--ports 80gcloud compute forwarding-rules list
Wait for around 2–3 minutes if the green check doesn’t appear. It takes time to create the resources. Check again and you’ll definitely see the green check.
Congratulations!!
This is the skill badge I got after completing this challenge lab :D
With this, we have come to the end of this lab. Thanks for reading this and following along.
Time to complete another quest!
See ya in the cloud :P
:wq