GSP-313: Create and Manage Cloud Resources

GSP-313: Create and Manage Cloud Resources

Overview

Please follow these commands:

Task 1 : Create a project jumphost instance

Please navigate to the compute engine > VM instance & click on create instance. Instance Name: As mentioned in the lab instruction Machine type: N1 (f1-macro) Do not change the other settings just click on the create.

Task 2 : Create a Kubernetes service cluster

 1gcloud container clusters create nucleus-backend \
 2          --num-nodes 1 \
 3          --network nucleus-vpc \
 4          --region us-east1
 5gcloud container clusters get-credentials nucleus-backend \
 6          --region us-east1
 7
 8kubectl create deployment hello-server \
 9          --image=gcr.io/google-samples/hello-app:2.0
10
11kubectl expose deployment hello-server \
12          --type=LoadBalancer \
13          --port <Use port given in the lab>

Task 3 : Set up an HTTP load balancer

1cat << EOF > startup.sh
2#! /bin/bash
3apt-get update
4apt-get install -y nginx
5service nginx start
6sed -i -- 's/nginx/Google Cloud Platform - '"\$HOSTNAME"'/' /var/www/html/index.nginx-debian.html
7EOF
 1gcloud compute instance-templates create web-server-template \
 2       --metadata-from-file startup-script=startup.sh \
 3       --network nucleus-vpc \
 4       --machine-type g1-small \
 5       --region us-east1
 6
 7gcloud compute target-pools create nginx-pool
 8
 9gcloud compute instance-groups managed create web-server-group \
10       --base-instance-name web-server \
11       --size 2 \
12       --template web-server-template \
13       --region us-east1
14
15gcloud compute firewall-rules create <Copy FIREWALL_NAME given in the lab> \
16       --allow tcp:80 \
17       --network nucleus-vpc
18
19gcloud compute http-health-checks create http-basic-check
20
21gcloud compute instance-groups managed \
22       set-named-ports web-server-group \
23       --named-ports http:80 \
24       --region us-east1
25
26gcloud compute backend-services create web-server-backend \
27       --protocol HTTP \
28       --http-health-checks http-basic-check \
29       --global
30
31gcloud compute backend-services add-backend web-server-backend \
32       --instance-group web-server-group \
33       --instance-group-region us-east1 \
34       --global
35
36gcloud compute url-maps create web-server-map \
37       --default-service web-server-backend
38
39gcloud compute target-http-proxies create http-lb-proxy \
40       --url-map web-server-map
41
42gcloud compute forwarding-rules create permit-tcp-rule-261 \
43     --global \
44     --target-http-proxy http-lb-proxy \
45     --ports 80
1gcloud compute forwarding-rules list

(Note: After running all the commands it can take upto 2-3 minutes to update the score for task 3) Congratulations, you're all done with the lab 😄