
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
Initialize Your Lab
/ 10
Create the Git repositories in Cloud Source Repositories
/ 10
Create a container image with Cloud Build
/ 10
Create the Continuous Integration (CI) Pipeline
/ 10
Grant Kubernetes Engine Developer and Source Repository Writer IAM role to cloud build
/ 10
Create the trigger for the continuous delivery pipeline
/ 10
Test the complete pipeline
/ 20
Test the rollback
/ 20
In this lab, you create a CI/CD pipeline that automatically builds a container image from committed code, stores the image in Container Registry, updates a Kubernetes manifest in a Git repository, and deploys the application to Google Kubernetes Engine using that manifest.
For this lab you will create 2 Git repositories:
When you push a change to the app repository, the Cloud Build pipeline runs tests, builds a container image, and pushes it to Artifact Registry. After pushing the image, Cloud Build updates the Deployment manifest and pushes it to the env repository. This triggers another Cloud Build pipeline that applies the manifest to the GKE cluster and, if successful, stores the manifest in another branch of the env repository.
We keep the app and env repositories separate because they have different lifecycles and uses. The main users of the app repository are actual humans and this repository is dedicated to a specific application. The main users of the env repository are automated systems (such as Cloud Build), and this repository might be shared by several applications. The env repository can have several branches that each map to a specific environment (you only use production in this lab) and reference a specific container image, whereas the app repository does not.
When you finish this lab, you have a system where you can easily:
In this lab, you learn how to perform the following tasks:
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
After you complete the initial sign-in steps, the project dashboard appears.
Google 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.
Google Cloud Shell provides command-line access to your Google Cloud resources.
In Cloud console, on the top right toolbar, click the Open Cloud Shell button.
Click Continue.
It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Example output:
Output:
Example output:
In this task you will prepare your Google Cloud Project for use by enabling the required APIs, initializing the git configuration in Cloud Shell, and downloading the sample code used later in the lab.
my-repository
in the Git will use these to identify you as the author of the commits you will create in Cloud Shell.
Click Check my progress to verify the objective.
In this task, you create the two Git repositories (hello-cloudbuild-app and hello-cloudbuild-env) used in this lab, and initialize hello-cloudbuild-app with some sample code.
The code you just cloned contains a simple "Hello World" application:
Click Check my progress to verify the objective.
The code you cloned already contains the following Dockerfile:
With this Dockerfile, you can create a container image with Cloud Build and store it in Container Registry.
Cloud Build streams the logs generated by the creation of the container image to your terminal when you execute this command.
After the build finishes, in the Google Cloud Console Artifact Registry > Repositories verify that your new container image is indeed available by in Artifact Registry.
Click my repository.
Click Check my progress to verify the objective.
In this task, you will configure Cloud Build to automatically run a small unit test, build the container image, and then push it to Container Registry. Pushing a new commit to Cloud Source Repositories triggers automatically this pipeline. The cloudbuild.yaml file already included in the code is the pipeline's configuration.
When the trigger is created, return to the Cloud Shell. You now need to push the application code to Cloud Source Repositories to trigger the CI pipeline in Cloud Build.
You should see a build running or having recently finished.
You can click on the build to follow its execution and examine its logs.
Click Check my progress to verify the objective.
Cloud Build is also used for the continuous delivery pipeline. The pipeline runs each time a commit is pushed to the candidate branch of the __hello-cloudbuild-env__repository. The pipeline applies the new version of the manifest to the Kubernetes cluster and, if successful, copies the manifest over to the production branch. This process has the following properties:
You will modify the continuous integration pipeline to update the candidate branch of the hello-cloudbuild-env repository, triggering the continuous delivery pipeline.
To deploy the application in your Kubernetes cluster, Cloud Build needs the Kubernetes Engine Developer Identity and Access Management Role.
You need to initialize the hello-cloudbuild-env repository with two branches (production and candidate) and a Cloud Build configuration file describing the deployment process.
The first step is to clone the hello-cloudbuild-env repository and create the production branch. It is still empty.
Click Check my progress to verify the objective.
In this section, you add some steps to the continuous integration pipeline that will generate a new version of the Kubernetes manifest and push it to the __hello-cloudbuild-env__repository to trigger the continuous delivery pipeline.
The cloudbuild-trigger-cd.yaml is an extended version of the cloudbuild.yaml file. It adds the steps below: they generate the new Kubernetes manifest and trigger the continuous delivery pipeline.
This triggers the continuous integration pipeline in Cloud Build.
Click Check my progress to verify the objective.
The last step of this pipeline pushes the new manifest to the hello-cloudbuild-env repository, which triggers the continuous delivery pipeline.
The complete CI/CD pipeline is now configured. In this section, you test it from end to end.
In the Google Cloud Console, Kubernetes Engine > Gateways, Services & Ingress.
Select Services on the top menu
There should be a single service called hello-cloudbuild in the list. It has been created by the continuous delivery build that just ran.
You should see "Hello World!". If there is no endpoint, or if you see a load balancer error, you may have to wait a few minutes for the load balancer to be completely initialized. Click Refresh to update the page if needed.
After a few minutes, reload the application in your browser. You should now see "Hello Cloud Build!".
Click Check my progress to verify the objective.
In this task, you rollback to the version of the application that said "Hello World!".
In the Google Cloud Console, Cloud Build > Dashboard.
Click on View all link under Build History for the hello-cloudbuild-env repository.
Click on the second most recent build available.
Click Retry build.
You should now see "Hello World!" again.
Click Check my progress to verify the objective.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
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