Time: 1 hour
Difficulty: Intermediate
Price: 5 Credits
Quest: Cloud Architecture: Design, Implement, and Manage
Last updated: May 25, 2023
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:
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
:
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
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.
-
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
-
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
. Changeimage=...:v1
toimage=...:v2
.image=gcr.io/qwiklabs-resources/echo-app:v2
Save the
deployment.apps
file, hit ESC then type:wq
and Enter. -
The Kubernetes cluster deployment reports 2 replicas.
kubectl scale deployment echo-web --replicas=2
-
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