You can configure automated deployments for your
workloads on
Google Kubernetes Engine (GKE).
This page shows you how to set up a simple
continuous integration/continuous delivery (CI/CD) pipeline for the workload.
When you push a change to your repository, Cloud Build automatically builds
and deploys the container to your GKE cluster.
How an automated deployment works
If you have a workload that references a
single-container image in GKE, you can configure an
automated deployment, so that your application is re-built and deployed each time a
code change is checked into the repository.
With an automated deployment, you define your workload as a YAML file and store that
YAML file in your repository (consistent with best practices). GKE
generates YAML that you can use for this purpose.
You have the following two options for using YAML files:
If you don't yet have a YAML file that defines your workload, you can use
the generated YAML file. Save the YAML file in your repository.
Cloud Build uses it to deploy your workload each time.
If you already have a YAML file that defines your workload, you can point
GKE to its location in your repository. You can compare the
YAML file in your repository with the recommended YAML file to ensure
you're deploying the correct workload in the correct way.
Before you begin
Before you start, make sure that you have performed the following tasks:
If you want to use the Google Cloud CLI for this task,
install and then
initialize the
gcloud CLI. If you previously installed the gcloud CLI, get the latest
version by running gcloud components update.
Automated deployments have the following requirements:
You can only use an automated deployment with workloads of type
Deployment that specify a single container image. Multi-container workloads
and other workload types (for example, ReplicaSet) are not supported.
Your source-code repository must contain a Dockerfile to build the image.
You can host this repository on one of the following products:
If you use GitHub or Bitbucket, you need to grant Google Cloud access to your
repository.
Store your container image in Artifact Registry, in the same
Google Cloud project as your GKE cluster. You need to have the
image in Artifact Registry, and you need to have
deployed it at
least once, so that you have a workload in GKE.
Creating the automated deployment
To create an automated deployment, perform the following steps:
Go to the Workloads page in the Google Cloud console.
In the workloads list, click the name of the Deployment you want to modify.
Click listActions > Automated deployment.
In the Automate deployment pane, perform the following steps:
Under Source repository, choose your source code repository:
In the Repository Provider drop-down list, choose the provider for your
repository
An automated deployment supports the following source control hosts:
Cloud Source Repositories
GitHub
Bitbucket
If you are using GitHub or Bitbucket, authenticate with your username
and password.
From the Repository drop-down list, select the name of the repository
containing the source code for your Deployment.
Click Continue.
Under Build configurations, specify the Build configuration information:
Enter the name of the branch from which you want to build, or a regular
expression (RegExp2)
to match the branch or branches. The default branch is master. When you push
to this branch, Cloud Build builds your application.
Enter the relative path of the Dockerfile directory.
Enter the Dockerfile name.
Select a service account to use when executing the build. If the service account is missing the roles/container.developer permission, grant the permission to the selected service account by clicking Grant all.
Click Continue.
Under Automated deployment configuration, provide the configuration YAML
file location.
The system automatically generates a YAML file, which you can use to
populate the YAML file in your repository.
Click View Google-recommended YAML to see the generated YAML file.
Compare it to your own YAML file, if you have it, and update yours based
on this one.
Otherwise, create a new file and populate it with the generated YAML. This
helps ensure the workload that gets deployed matches what's currently
running. The file can have any name, but must have a .yaml or .yml
extension.
Specify the relative path to the directory that contains the YAML file.
If there is more than one YAML file in the specified directory,
GKE uses all of them.
Click Set Up to finish configuring your automated deployment.
What happens next
After you set up automated deployment for the selected workload, you have a
Cloud Build
trigger that builds a container image after a push to the selected branch
of the repository. Cloud Build also deploys a new revision of your
workload to the cluster where the original image was deployed.
For more information on your workload, see the Deployment Details page
(Revision History tab).
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-26 UTC."],[],[],null,["# Setting up automated deployments\n\n[Autopilot](/kubernetes-engine/docs/concepts/autopilot-overview) [Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nYou can configure automated deployments for your\n[workloads](/kubernetes-engine/docs/how-to/deploying-workloads-overview) on\nGoogle Kubernetes Engine (GKE).\n\nThis page shows you how to set up a simple\ncontinuous integration/continuous delivery (CI/CD) pipeline for the workload.\nWhen you push a change to your repository, Cloud Build automatically builds\nand deploys the container to your GKE cluster.\n| **Note:** You can set up a continuous-delivery pipeline to deploy to a progression of GKE clusters, with optional manual approval for any target cluster. For more information, see [Cloud Deploy](/deploy/docs/overview).\n\nHow an automated deployment works\n---------------------------------\n\nIf you have a workload that references a\nsingle-container image in GKE, you can configure an\nautomated deployment, so that your application is re-built and deployed each time a\ncode change is checked into the repository.\n\nWith an automated deployment, you define your workload as a YAML file and store that\nYAML file in your repository (consistent with best practices). GKE\ngenerates YAML that you can use for this purpose.\n\nYou have the following two options for using YAML files:\n\n- If you don't yet have a YAML file that defines your workload, you can use\n the generated YAML file. Save the YAML file in your repository.\n Cloud Build uses it to deploy your workload each time.\n\n- If you already have a YAML file that defines your workload, you can point\n GKE to its location in your repository. You can compare the\n YAML file in your repository with the recommended YAML file to ensure\n you're deploying the correct workload in the correct way.\n\nBefore you begin\n----------------\n\nBefore you start, make sure that you have performed the following tasks:\n\n- Enable the Google Kubernetes Engine API.\n[Enable Google Kubernetes Engine API](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com)\n- If you want to use the Google Cloud CLI for this task, [install](/sdk/docs/install) and then [initialize](/sdk/docs/initializing) the gcloud CLI. If you previously installed the gcloud CLI, get the latest version by running `gcloud components update`. **Note:** For existing gcloud CLI installations, make sure to set the `compute/region` [property](/sdk/docs/properties#setting_properties). If you use primarily zonal clusters, set the `compute/zone` instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: `One of [--zone, --region] must be supplied: Please specify location`. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.\n\n\u003c!-- --\u003e\n\n- Enable the following additional APIs:\n\n - Cloud Build\n\n [Enable Cloud Build API](https://console.cloud.google.com/apis/library/cloudbuild.googleapis.com?q=cloud%20build)\n - Cloud Source Repositories\n\n [Enable Cloud Source Repositories API](https://console.cloud.google.com/apis/library/sourcerepo.googleapis.com?q=source%20repositories)\n - Artifact Registry\n\n [Enable Artifact Registry API](https://console.cloud.google.com/apis/library/artifactregistry.googleapis.com)\n\nRequirements\n------------\n\nAutomated deployments have the following requirements:\n\n- You can only use an automated deployment with workloads of type\n `Deployment` that specify a single container image. Multi-container workloads\n and other workload types (for example, `ReplicaSet`) are not supported.\n\n- Your source-code repository must contain a Dockerfile to build the image.\n\n You can host this repository on one of the following products:\n - [Cloud Source Repositories](/source-repositories)\n - GitHub\n - Bitbucket\n\n If you use GitHub or Bitbucket, you need to grant Google Cloud access to your\n repository.\n- Store your container image in Artifact Registry, in the same\n Google Cloud project as your GKE cluster. You need to have the\n image in Artifact Registry, and you need to have\n [deployed](/kubernetes-engine/docs/how-to/deploying-workloads-overview) it at\n least once, so that you have a workload in GKE.\n\nCreating the automated deployment\n---------------------------------\n\nTo create an automated deployment, perform the following steps:\n\n1. Go to the **Workloads** page in the Google Cloud console.\n\n [Go to Workloads](https://console.cloud.google.com/kubernetes/workload)\n2. In the workloads list, click the name of the Deployment you want to modify.\n\n3. Click *list* **Actions \\\u003e Automated deployment**.\n\nIn the **Automate deployment** pane, perform the following steps:\n\n1. Under **Source repository**, choose your source code repository:\n\n 1. In the **Repository Provider** drop-down list, choose the provider for your\n repository\n\n An automated deployment supports the following source control hosts:\n - Cloud Source Repositories\n - GitHub\n - Bitbucket\n\n If you are using GitHub or Bitbucket, authenticate with your username\n and password.\n | **Note:** An automated deployment creates a mirror of your GitHub or Bitbucket repositories on Cloud Source Repositories. When you push changes to your original repository, Cloud Source Repositories picks up the changes automatically.\n 2. From the **Repository** drop-down list, select the name of the repository\n containing the source code for your Deployment.\n\n 3. Click **Continue**.\n\n2. Under **Build configurations**, specify the Build configuration information:\n\n 1. Enter the name of the branch from which you want to build, or a regular expression ([RegExp2](https://github.com/google/re2/wiki/Syntax)) to match the branch or branches. The default branch is `master`. When you push to this branch, Cloud Build builds your application.\n 2. Enter the relative path of the **Dockerfile directory**.\n 3. Enter the **Dockerfile name**.\n\n | **Note:** The **Image name** field is automatically generated based on the repository name.\n 4. Select a service account to use when executing the build. If the service account is missing the **roles/container.developer** permission, grant the permission to the selected service account by clicking **Grant all**.\n\n 5. Click **Continue**.\n\n3. Under **Automated deployment configuration**, provide the configuration YAML\n file location.\n\n The system automatically generates a YAML file, which you can use to\n populate the YAML file in your repository.\n 1. Click **View Google-recommended YAML** to see the generated YAML file.\n\n 2. Compare it to your own YAML file, if you have it, and update yours based\n on this one.\n\n Otherwise, create a new file and populate it with the generated YAML. This\n helps ensure the workload that gets deployed matches what's currently\n running. The file can have any name, but must have a `.yaml` or `.yml`\n extension.\n 3. Specify the relative path to the directory that contains the YAML file.\n\n If there is more than one YAML file in the specified directory,\n GKE uses all of them.\n4. Click **Set Up** to finish configuring your automated deployment.\n\nWhat happens next\n-----------------\n\nAfter you set up automated deployment for the selected workload, you have a\n[Cloud Build\ntrigger](/build/docs/automating-builds/create-manage-triggers) that builds a container image after a push to the selected branch\nof the repository. Cloud Build also deploys a new revision of your\nworkload to the cluster where the original image was deployed.\n\nFor more information on your workload, see the **Deployment Details** page\n(Revision History tab)."]]