GSP313 Create and Manage Cloud Resources: Challenge Lab
Challenge Lab: https://google.qwiklabs.com/focuses/10258?parent=catalog
#
Lab Video#
SetupSet Default Compute Zone and Region
gcloud config set compute/zone us-east1-bgcloud config set compute/region us-east1
#
Task 1: Create a project jumphost instanceCreate an instance with command line
gcloud compute instances create nucleus-jumphost \ --machine-type f1-micro
#
Task 2: Create a Kubernetes service cluster#
Create a GKE clustergcloud container clusters create my-cluster
#
Get authentication credentials for the clustergcloud container clusters get-credentials my-cluster
#
Deploy an application to the clusterkubectl create deployment hello-server --image gcr.io/google-samples/hello-app:2.0
#
Expose your application to external traffickubectl expose deployment hello-server --type LoadBalancer --port 8080
#
Check if service is up and runningkubectl get service
#
Task 3: Set up an HTTP load balancer#
Create Startup Scriptcat << EOF > startup.sh#! /bin/bashapt-get updateapt-get install -y nginxservice nginx startsed -i -- 's/nginx/Google Cloud Platform - '"\$HOSTNAME"'/' /var/www/html/index.nginx-debian.htmlEOF
#
Create Instance Templategcloud compute instance-templates create nginx-server-template \ --metadata-from-file startup-script=startup.sh \ --network nucleus-vpc \ --machine-type f1-micro
#
Create Managed Instance Groupgcloud compute instance-groups managed create nginx-server-group \ --base-instance-name nginx-server \ --size 2 \ --template nginx-server-template
#
Firewall rulegcloud compute firewall-rules create nginx-server-firewall \ --allow tcp:80 \ --network nucleus-vpc
#
Create a health checkgcloud compute http-health-checks create http-basic-check
#
Set Named Portgcloud compute instance-groups managed \ set-named-ports nginx-server-group \ --named-ports http:80
#
Create a backend servicegcloud compute backend-services create nginx-server-backend \ --protocol HTTP \ --http-health-checks http-basic-check \ --global
#
Attach the managed instance group to a backend servicegcloud compute backend-services add-backend nginx-server-backend \ --instance-group nginx-server-group \ --global
#
Create a URL mapgcloud compute url-maps create nginx-server-map \ --default-service nginx-server-backend
#
Target the HTTP proxy to route requests to your URL mapgcloud compute target-http-proxies create http-lb-proxy \ --url-map nginx-server-map
#
Forwarding Rulegcloud compute forwarding-rules create http-content-rule \ --global \ --target-http-proxy http-lb-proxy \ --ports 80
#
Get a list of Forwarding Rulesgcloud compute forwarding-rules list