
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Configure the Quiz application
/ 20
Create Kubernetes engine cluster
/ 20
Create a Docker Repository on Artifact registry
/ 10
Build Docker Images using Cloud Build
/ 20
Create Kubernetes Deployment and Service Resources
/ 30
Google Kubernetes Engine provides a managed environment for deploying, managing, and scaling your containerized applications using Google infrastructure. The environment Kubernetes Engine provides consists of multiple machines (specifically, Compute Engine instances) grouped together to form a cluster.
Kubernetes provides the mechanisms through which you interact with your cluster. You use Kubernetes commands and resources to deploy and manage your applications, perform administration tasks and set policies, and monitor the health of your deployed workloads.
In this lab, you deploy the Quiz application into Kubernetes Engine, leveraging Google Cloud resources, including Cloud Build and Artifact Registry, and Kubernetes resources, such as Deployments, Pods, and Services.
In this lab, you learn how to perform the following tasks:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
From Cloud Shell, click Open Editor to launch the code editor.
In this section, you access Cloud Shell, clone the git repository containing the Quiz application, configure environment variables, and run the application.
This script file:
GCLOUD_PROJECT
and GCLOUD_BUCKET
.pip install -r requirements.txt
.The Quiz application is configured when you see the following message:
Example output message
Click Check my progress to verify the objective.
In this section you examine the application files.
To view and edit files, you can use the shell editors that are installed in Cloud Shell, such as nano
or vim
or the Cloud Shell Editor. This lab uses the Cloud Shell Editor.
training-data-analyst/courses/developingapps/v1.2/python/kubernetesengine/start
.The folder structure for the Quiz application reflects how it will be deployed in Kubernetes Engine.
The web application is in a folder called frontend
.
The worker application code that subscribes to Cloud Pub/Sub and processes messages is in a folder called backend
.
There are configuration files for Docker (a Dockerfile
in the frontend
and backend
folder) and backend-deployment
and frontend-deployment
Kubernetes Engine .yaml
files.
In this section you use Google Cloud console to create and then connect to a Kubernetes Engine cluster.
In the console, click Navigation menu ()> Kubernetes Engine > Clusters.
Click Create.
Click Configure for Standard demo. Set the following fields to the provided values, leave all others at the default value:
Property |
Value |
Name |
|
Zonal |
|
default Pool > Security > Access scopes |
Select Allow full access to all Cloud APIs |
Click Create. The cluster takes a few minutes to provision.
Click Check my progress to verify the objective.
In this section you connect the Quiz application to the kubernetes cluster.
Press ENTER to run the command in Cloud Shell.
The response should be No resources found in default namespace
because there are no Pods in the cluster. It confirms that you have configured security to allow the kubectl
command-line tool to perform operations against the cluster.
Artifact Registry supports managing container images and language packages. Different artifact types require different specifications. For example, the requests for Maven dependencies are different from requests for Node dependencies.
To support the different API specifications, Artifact Registry needs to know what format you want the API responses to follow. To do this you will create a repository and pass in the --repository-format
flag indicating the type of repository desired.
Click Authorize if the Cloud Shell authorization prompt appears.
container-dev-repo
. If you click on it you can see that it's empty at the moment.Click Check my progress to verify the objective.
In this section, you create a Dockerfile for the application frontend and backend, and then employ Cloud Build to build images and store them in the Artifact Registry.
frontend/Dockerfile
.pip install
as part of the build process./app
path in the container.Dockerfile
by entering the statement, gunicorn ...
, that executes when the container runs. Gunicorn (Green Unicorn) is an HTTP server that supports the Python Web Server Gateway Interface (WSGI) specification.Copy and paste the following to Dockerfile
:
backend/Dockerfile
file and copy and paste the following code:start
folder:Here, Docker image is built and stored in the Artifact Registry. It takes a few minutes.
Ignore any incompatibility messages you see in the output messages.
When the backend Docker image is ready you see these last messages:
In the console, from the Navigation menu menu, click Artifact Registry, then select container-dev-repo.
You should see two Pods: quiz-frontend
and quiz-backend
.
Click quiz-frontend.
Click Check my progress to verify the objective.
In this section, you modify the template yaml
files that contain the specification for Kubernetes Deployment and Service resources, and then create the resources in the Kubernetes Engine cluster.
frontend-deployment.yaml
file.frontend-deployment.yaml
file using the following values:
Placeholder Name |
Value |
|
Project ID |
|
Cloud Storage bucket name for the media bucket in your project |
|
The frontend image identified in the form |
backend-deployment.yaml
file using the following values:
Placeholder Name |
Value |
|
Project ID |
|
Cloud Storage bucket ID for the media bucket in your project |
|
The backend image identified in the form |
frontend-service.yaml
file.Click Check my progress to verify the objective.
In this section you review the deployed Pods and service and navigate to the Quiz application.
If the status of one or both containers is Does not have minimum availability, refresh the window.
Click quiz-frontend. In the Managed Pods section, there are three quiz-frontend Pods.
In the Exposing services section near the bottom, find the Endpoints section and copy the IP address and paste it into the URL field of a new browser tab or window:
This concludes the self-paced lab, App Dev: Deploying the Application into Kubernetes Engine - Python. You leveraged Google Cloud resources and Kubernetes resources to deploy a Quiz application.
Learn more about Kubernetes Engine.
Manual Last Updated December 17, 2024
Lab Last Tested December 17, 2024
Copyright 2025 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one