☁️
Cloud Computing
  • Introduction
  • Terminologies
    • Container
    • Kubernetes (K8s)
    • Serverless Computing
  • Services
    • Docker
    • Terraform
  • ☁️Cloud Computing Platforms
    • Google Cloud
      • Google Cloud Essentials
      • Management
        • Cloud IAM
      • Compute
        • Compute Engine
        • Kubernetes Engine
      • Resources
    • IBM Cloud
      • IBM Cloud Shell
      • Compute
      • Containers
      • Developer tools
      • Integration
      • Storage
      • Cloud Paks
    • Microsoft Azure
      • Compute
        • Functions
        • App Services
      • Networking
      • Storage
      • Web
      • Mobile
      • Databases
        • Cosmos DB
      • Analytics
      • AI + Machine Learning
      • Internet of things
      • Security
      • DevOps
      • Monitoring
      • Management and governance
      • Azure Stack
    • Amazon Web Services
    • Resources
  • Qwiklabs Challenge Labs
    • Create and Manage Cloud Resources
    • Deploy and Manage Cloud Environments with Google Cloud
    • Create ML Models with BigQuery ML
    • Insights from Data with BigQuery
    • Build a Website on Google Cloud
    • Build and Deploy a Docker Image to a Kubernetes Cluster
    • Build and Secure Networks in Google Cloud
    • Set Up and Configure a Cloud Environment in Google Cloud
    • Build and Optimize Data Warehouses with BigQuery: Challenge Lab
    • Scale Out and Update a Containerized Application on a Kubernetes Cluster
  • Whizlabs Challenge League
Powered by GitBook
On this page
  • Task 1: Create a project jumphost instance
  • Task 2: Create a Kubernetes service cluster
  • Task 3: Set up an HTTP load balancer

Was this helpful?

  1. Qwiklabs Challenge Labs

Create and Manage Cloud Resources

Task 1: Create a project jumphost instance

You will use this instance to perform maintenance for the project.

Requirements:

  • Name the instance nucleus-jumphost.

  • Use an f1-micro machine type.

  • Use the default image type (Debian Linux).

gcloud compute instances create nucleus-jumphost \
    --machine-type f1-micro \
    --zone us-east1-b

Task 2: Create a Kubernetes service cluster

The team is building an application that will use a service running on Kubernetes.

You need to:

  • Create a cluster (in the us-east1-b zone) to host the service.

gcloud container clusters create service-cluster \
    --zone us-east1-b
gcloud container clusters get-credentials service-cluster \
    --zone us-east1-b
  • Use the Docker container hello-app (gcr.io/google-samples/hello-app:2.0) as a placeholder; the team will replace the container with their own work later.

kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:2.0
  • Expose the app on port 8080.

kubectl expose deployment hello-server --type=LoadBalancer --port 8080

Task 3: Set up an HTTP load balancer

You will serve the site via nginx web servers, but you want to ensure that the environment is fault-tolerant. Create an HTTP load balancer with a managed instance group of 2 nginx web servers. Use the following code to configure the web servers; the team will replace this with their own configuration later.

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

You need to:

  • Create an instance template.

gcloud compute instance-templates create nginx-template \
--metadata-from-file startup-script=startup.sh
  • Create a target pool.

gcloud compute target-pools create nginx-pool
  • Create 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

  • Create 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

  • Create 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
  • Create a backend service, and attach the managed 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
  • Create a URL map, and target the 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
  • Create 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

PreviousQwiklabs Challenge LabsNextDeploy and Manage Cloud Environments with Google Cloud

Last updated 3 years ago

Was this helpful?