lemniskett.moe/content/writeups/google-cloudskillsboost/GSP305/index.md
2023-09-07 08:22:00 +07:00

4.8 KiB

title description summary date draft author tags canonicalURL showToc TocOpen TocSide weight hidemeta comments disableHLJS disableShare hideSummary searchHidden ShowReadingTime ShowBreadCrumbs ShowPostNavLinks ShowWordCount ShowRssButtonInSectionTermList cover
[GSP305] Scale Out and Update a Containerized Application on a Kubernetes Cluster Quest: Cloud Architecture: Design, Implement, and Manage 2023-05-25T07:55:03+07:00 false Hiiruki
writeups
challenge
google-cloudskillsboost
gsp305
google-cloud
cloudskillsboost
juaragcp
google-cloud-platform
gcp
container
kubernetes
cloud-computing
cloud
cloud-architecture
true false right 5 false false true true false false true true true true true
image alt caption relative hidden
<image path/url> <alt text> <text> false true

GSP305

Lab Banner

  • Time: 1 hour
  • Difficulty: Intermediate
  • Price: 5 Credits

Lab: GSP305
Quest: Cloud Architecture: Design, Implement, and Manage

🔄 Last updated: Sep 7, 2023

Challenge scenario

You are taking over ownership of a test environment and have been given an updated version of a containerized test application to deploy. Your systems' architecture team has started adopting a containerized microservice architecture. You are responsible for managing the containerized test web applications. You will first deploy the initial version of a test application, called echo-app to a Kubernetes cluster called echo-cluster in a deployment called echo-web.

Before you get started, open the navigation menu and select Cloud Storage. The last steps in the Deployment Manager script used to set up your environment creates a bucket.

Refresh the Storage browser until you see your bucket. You can move on once your Console resembles the following:

bucket

Check to make sure your GKE cluster has been created before continuing. Open the navigation menu and select Kubernetes Engine > Clusters.

Continue when you see a green checkmark next to echo-cluster:

kubernetes cluster

To deploy your first version of the application, run the following commands in Cloud Shell to get up and running:

gcloud container clusters get-credentials echo-cluster --zone=us-central1-a
kubectl create deployment echo-web --image=gcr.io/qwiklabs-resources/echo-app:v1
kubectl expose deployment echo-web --type=LoadBalancer --port 80 --target-port 8000

Your challenge

You need to update the running echo-app application in the echo-web deployment from the v1 to the v2 code you have been provided. You must also scale out the application to 2 instances and confirm that they are all running.

  1. Check that there is a tagged image in gcr.io for echo-app:v2.

    mkdir echo-web
    cd echo-web
    gsutil cp -r gs://$DEVSHELL_PROJECT_ID/echo-web-v2.tar.gz .
    tar -xzf echo-web-v2.tar.gz
    rm echo-web-v2.tar.gz
    docker build -t echo-app:v2 .
    docker tag echo-app:v2 gcr.io/$DEVSHELL_PROJECT_ID/echo-app:v2
    docker push gcr.io/$DEVSHELL_PROJECT_ID/echo-app:v2
    
  2. Echo-app:v2 is running on the Kubernetes cluster.

    Deploy the first version of the application.

    gcloud container clusters get-credentials echo-cluster --zone=us-central1-a
    kubectl create deployment echo-web --image=gcr.io/qwiklabs-resources/echo-app:v1
    kubectl expose deployment echo-web --type=LoadBalancer --port 80 --target-port 8000
    

    Edit the deployment.apps file.

    kubectl edit deploy echo-web
    

    Start the editor by type i. Change image=...:v1 to image=...:v2.

    image=gcr.io/qwiklabs-resources/echo-app:v2

    Save the deployment.apps file, hit ESC then type :wq and Enter.

  3. The Kubernetes cluster deployment reports 2 replicas.

    kubectl scale deployment echo-web --replicas=2
    
  4. The application must respond to web requests with V2.0.0.

    kubectl expose deployment echo-web --type=LoadBalancer --port 80 --target-port 8000
    
    kubectl get svc
    

Congratulations!