GSP313 Create and Manage Cloud Resources: Challenge Lab
Challenge Lab: https://google.qwiklabs.com/focuses/10258?parent=catalog
Lab Video#
Setup#
Set Default Compute Zone and Region
gcloud config set compute/zone us-east1-bgcloud config set compute/region us-east1Task 1: Create a project jumphost instance#
Create an instance with command line
gcloud compute instances create nucleus-jumphost \ --machine-type f1-microTask 2: Create a Kubernetes service cluster#
Create a GKE cluster#
gcloud container clusters create my-clusterGet authentication credentials for the cluster#
gcloud container clusters get-credentials my-clusterDeploy an application to the cluster#
kubectl create deployment hello-server --image gcr.io/google-samples/hello-app:2.0Expose your application to external traffic#
kubectl expose deployment hello-server --type LoadBalancer --port 8080Check if service is up and running#
kubectl get serviceTask 3: Set up an HTTP load balancer#
Create Startup Script#
cat << 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.htmlEOFCreate Instance Template#
gcloud compute instance-templates create nginx-server-template \ --metadata-from-file startup-script=startup.sh \ --network nucleus-vpc \ --machine-type f1-microCreate Managed Instance Group#
gcloud compute instance-groups managed create nginx-server-group \ --base-instance-name nginx-server \ --size 2 \ --template nginx-server-templateFirewall rule#
gcloud compute firewall-rules create nginx-server-firewall \ --allow tcp:80 \ --network nucleus-vpcCreate a health check#
gcloud compute http-health-checks create http-basic-checkSet Named Port#
gcloud compute instance-groups managed \ set-named-ports nginx-server-group \ --named-ports http:80Create a backend service#
gcloud compute backend-services create nginx-server-backend \ --protocol HTTP \ --http-health-checks http-basic-check \ --globalAttach the managed instance group to a backend service#
gcloud compute backend-services add-backend nginx-server-backend \ --instance-group nginx-server-group \ --globalCreate a URL map#
gcloud compute url-maps create nginx-server-map \ --default-service nginx-server-backendTarget the HTTP proxy to route requests to your URL map#
gcloud compute target-http-proxies create http-lb-proxy \ --url-map nginx-server-mapForwarding Rule#
gcloud compute forwarding-rules create http-content-rule \ --global \ --target-http-proxy http-lb-proxy \ --ports 80Get a list of Forwarding Rules#
gcloud compute forwarding-rules list