Google Cloud Deploy is a managed service that automates delivery of your applications to a series of target environments in a defined promotion sequence. When you want to deploy your updated application, you create a release, whose lifecycle is managed by a delivery pipeline.
In this lab, you will create a delivery pipeline using Google Cloud Deploy. You will then create a release for a basic application and promote the application through a series of Google Kubernetes Engine (GKE) targets.
The sample application is a simple web app that listens to a port, provides an HTTP response code and adds a log entry. This lab is derived from a tutorial published by Google: https://cloud.google.com/deploy/docs/tutorials.
Objectives
In this lab, you learn how to perform the following tasks:
Deploy a container image to Google Cloud Artifact Registry using Skaffold
Create a Google Cloud Deploy delivery pipeline
Create a release for the delivery pipeline
Promote the application through the targets in the delivery pipeline
Setup
Before you click the Start Lab button
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:
Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.
How to start your lab and sign in to the Google Cloud console
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:
The Open Google Cloud console button
Time remaining
The temporary credentials that you must use for this lab
Other information, if needed, to step through this lab
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.
Note: If you see the Choose an account dialog, click Use Another Account.
If necessary, copy the Username below and paste it into the Sign in dialog.
{{{user_0.username | "Username"}}}
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
{{{user_0.password | "Password"}}}
You can also find the Password in the Lab Details pane.
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials.
Note: Using your own Google Cloud account for this lab may incur extra charges.
Click through the subsequent pages:
Accept the terms and conditions.
Do not add recovery options or two-factor authentication (because this is a temporary account).
Do not sign up for free trials.
After a few moments, the Google Cloud console opens in this tab.
Note: To access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field.
Activate Cloud Shell
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:
Continue through the Cloud Shell information window.
Authorize Cloud Shell to use your credentials to make Google Cloud API calls.
When you are connected, you are already authenticated, and the project is set to your Project_ID, . The output contains a line that declares the Project_ID for this session:
Your Cloud Platform project in this session is set to {{{project_0.project_id | "PROJECT_ID"}}}
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
(Optional) You can list the active account name with this command:
gcloud auth list
Click Authorize.
Output:
ACTIVE: *
ACCOUNT: {{{user_0.username | "ACCOUNT"}}}
To set the active account, run:
$ gcloud config set account `ACCOUNT`
(Optional) You can list the project ID with this command:
gcloud config list project
Output:
[core]
project = {{{project_0.project_id | "PROJECT_ID"}}}
Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.
Task 1. Set variables
Declare the environment variables that will be used by various commands:
Create the web-app repository for holding container images:
gcloud artifacts repositories create web-app \
--description="Image registry for tutorial web app" \
--repository-format=docker \
--location=$REGION
Click Check my progress to verify the objective.
Create the web-app repository
Task 4. Build and deploy the container images to the Artifact Registry
In this task you will clone the git repository containing the web application and deploy the application's container images to Artifact Registry.
Prepare the application configuration
Clone the repository for the lab into your home directory:
cd ~/
git clone https://github.com/GoogleCloudPlatform/cloud-deploy-tutorials.git
cd cloud-deploy-tutorials
git checkout c3cae80 --quiet
cd tutorials/base
The web directory now contains the skaffold.yaml configuration file, which provides instructions for Skaffold to build a container image for your application. This configuration describes the following items.
The build section configures:
The two container images that will be built (artifacts)
The Google Cloud Build project used to build the images
The deploy section configures the Kubernetes manifests needed in deploying the workload to a cluster.
The portForward configuration is used to define the Kubernetes service for the deployment.
Output
apiVersion: skaffold/v2beta7
kind: Config
build:
artifacts:
- image: leeroy-web
context: leeroy-web
- image: leeroy-app
context: leeroy-app
googleCloudBuild:
projectId: {{project-id}}
deploy:
kubectl:
manifests:
- leeroy-web/kubernetes/*
- leeroy-app/kubernetes/*
portForward:
- resourceType: deployment
resourceName: leeroy-web
port: 8080
localPort: 9000
Note: To view the files, use vi, emacs, nano or the Cloud Shell Code Editor by clicking on the Open Editor icon in Cloud Shell.
Build the web application
The skaffold tool will handle submission of the codebase to Cloud Build.
Enable the Cloud Build API:
gcloud services enable cloudbuild.googleapis.com
Create a Cloud Storage bucket for Cloud Build to store sources and logs.
By default, Skaffold sets the tag for an image to its related git tag if one is available. Similar information can be found in the artifacts.json file that was created by the skaffold command.
Skaffold generates the web/artifacts.json file with details of the deployed images:
The delivery pipeline will appear similar to the following output:
Output
Unable to get target test
Unable to get target staging
Unable to get target prod
Delivery Pipeline:
createTime: '2021-08-16T14:03:18.294884547Z'
description: web-app delivery pipeline
etag: 2539eacd7f5c256d
name: projects/{{project-id}}/locations/us-central1/deliveryPipelines/web-app
serialPipeline:
stages:
- targetId: test
- targetId: staging
- targetId: prod
uid: eb0601aa03ac4b088d74c6a5f13f36ae
updateTime: '2021-08-16T14:03:18.680753520Z'
Targets: []
Notice the first three lines of the output. The delivery pipeline currently references three target environments that haven't been created yet. In the next task you will create those targets.
Click Check my progress to verify the objective.
Create the delivery pipeline
Task 6. Configure the deployment targets
Three delivery pipeline targets will be created - one for each of the GKE clusters.
Ensure that the clusters are ready
The three GKE clusters should now be running, but it's useful to verify this.
Run the following to get the status of the clusters:
gcloud container clusters list --format="csv(name,status)"
All three clusters should be in the RUNNING state, as indicated in the output below. If they are not yet marked as RUNNING, retry the command above until their status has changed to RUNNING.
Once all the clusters have the "RUNNING" status continue the lab.
Create a context for each cluster
Use the commands below to get the credentials for each cluster and create an easy-to-use kubectl context for referencing the clusters later:
CONTEXTS=("test" "staging" "prod")
for CONTEXT in ${CONTEXTS[@]}
do
gcloud container clusters get-credentials ${CONTEXT} --region ${REGION}
kubectl config rename-context gke_${PROJECT_ID}_${REGION}_${CONTEXT} ${CONTEXT}
done
Create a namespace in each cluster
Use the commands below to create a Kubernetes namespace (web-app) in each of the three clusters:
for CONTEXT in ${CONTEXTS[@]}
do
kubectl --context ${CONTEXT} apply -f kubernetes-config/web-app-namespace.yaml
done
The application will be deployed to the (web-app) namespace.
Create the delivery pipeline targets
Submit a target definition for each of the targets:
for CONTEXT in ${CONTEXTS[@]}
do
envsubst < clouddeploy-config/target-$CONTEXT.yaml.template > clouddeploy-config/target-$CONTEXT.yaml
gcloud beta deploy apply --file clouddeploy-config/target-$CONTEXT.yaml
done
The targets are described in a yaml file. Each target configures the relevant cluster information for the target. The test and staging target configurations are mostly the same.
Display the details for the test Target:
cat clouddeploy-config/target-test.yaml
Output
apiVersion: deploy.cloud.google.com/v1beta1
kind: Target
metadata:
name: test
description: test cluster
gke:
cluster: projects/{{project-id}}/locations/us-central1/clusters/test
The prod target is slightly different as it requires approval (see the requireApproval setting in the output) before a release can be promoted to the cluster.
Verify the three targets (test, staging, prod) have been created:
gcloud beta deploy targets list
All Google Cloud Deploy targets for the delivery pipeline have now been created.
Click Check my progress to verify the objective.
Configure the deployment targets
Task 7. Create a release
In this task you create a release of the application.
A Google Cloud Deploy release is a specific version of one or more container images associated with a specific delivery pipeline. Once a release is created, it can be promoted through multiple targets (the promotion sequence). Additionally, creating a release renders your application using skaffold and saves the output as a point-in-time reference that's used for the duration of that release.
Since this is the first release of your application, you'll name it web-app-001.
The --build-artifacts parameter references the artifacts.json file created by skaffold earlier. The --source parameter references the application source directory where skaffold.yaml can be found.
When a release is created, it will also be automatically rolled out to the first target in the pipeline (unless approval is required, which will be covered in a later step of this lab).
To confirm the test target has your application deployed, run the following command:
The first rollout of a release will take several minutes because Google Cloud Deploy renders the manifests for all targets when the release is created. The GKE cluster may also take a few minutes to provide the resources required by the deployment.
If you do not see state: SUCCESS in the output from the previous command, please wait and periodically re-run the command until the rollout completes.
Confirm your application was deployed to the test GKE cluster by running the following commands:
kubectx test
kubectl get all -n web-app
Output
NAME READY STATUS RESTARTS AGE
pod/leeroy-app-5547cf9d9b-rgc2l 1/1 Running 0 3m27s
pod/leeroy-web-6768b49c46-w7vt9 1/1 Running 0 3m27s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/leeroy-app ClusterIP None <none> 50051/TCP 3m28s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/leeroy-app 1/1 1 1 3m28s
deployment.apps/leeroy-web 1/1 1 1 3m28s
NAME DESIRED CURRENT READY AGE
replicaset.apps/leeroy-app-5547cf9d9b 1 1 1 3m28s
replicaset.apps/leeroy-web-6768b49c46 1 1 1 3m28s
Click Check my progress to verify the objective.
Create a release
Task 8. Promote the application to staging
In this task you will promote the application from test and into the staging target.
Look for the section marked targetId: staging. As before, if you do not see state: SUCCEEDED in the output from the previous command, wait and periodically re-run the command until the rollout completes.
As for previous rollouts, locate the entry for the target (targetId: prod) and check that the rollout has completed (state: SUCCEEDED). Periodically re-run the command until the rollout completes.
Use kubectl to check on the status of the deployed application:
kubectx prod
kubectl get all -n web-app
Click Check my progress to verify the objective.
Promote the application to prod
Congratulations!
Congratulations! In this lab, you learned how to create a delivery pipeline using Google Cloud Deploy. You created a release for a basic application and promoted the application through a series of Google Kubernetes Engine (GKE) targets. You first deployed the application to the test target, then promoted it to the staging target, and finally to the prod target. Now you can use Cloud Deploy to create continuous delivery pipelines!
Google Cloud training and certification
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated May 15, 2025
Lab Last Tested May 15, 2025
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.
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
Use private browsing
Copy the provided Username and Password for the lab
Click Open console in private mode
Sign in to the Console
Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
Accept the terms, and skip the recovery resource page
Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project
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
Use private browsing to run the lab
Use an Incognito or private browser window to run this lab. This
prevents any conflicts between your personal account and the Student
account, which may cause extra charges incurred to your personal account.
Create a delivery pipeline using Google Cloud Deploy, create a release for a basic application, and promote the application through a series of Google Kubernetes Engine targets