Tuesday, March 4, 2025
GCP

Create and Manage Cloud Resources: Challenge Lab

manage

“Create and Manage Cloud Resources: Challenge Lab”

Solusi

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. 

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-b
gcloud container clusters create nucleus-jumphost-webserver1
gcloud container clusters get-credentials nucleus-jumphost-webserver1
kubectl create deployment hello-app --image=gcr.io/google-samples/hello-app:2.0
kubectl expose deployment hello-app --type=LoadBalancer --port 8080
kubectl 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!


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:

1. 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 19. Type 19 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-pool
gcloud compute instances list

4. Creating a firewall rule to allow traffic (80/tcp):

gcloud compute firewall-rules create www-firewall --allow tcp:80
gcloud compute forwarding-rules create nginx-lb \
--region us-east1 \
--ports=80 \
--target-pool nginx-pool
gcloud compute forwarding-rules list

5. Creating 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

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 --global
gcloud 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-backend
gcloud 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 80
gcloud 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.

Penutup

Baca Juga :  Monitor Environments with Google Cloud Managed Service for Prometheus: Challenge Lab

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Create and Manage Cloud Resources: Challenge Lab. Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

(Visited 421 times, 1 visits today)

Similar Posts