GitOps-style Continuous Delivery For Kubernetes Engine With Cloud Build

This repository contains the code used in the GitOps-style Continuous Delivery with Cloud Build tutorial.

GitOps is a Continuous Delivery approach first described by Weaveworks that is popular in the Kubernetes community. A key part of GitOps is the idea of "environments-as-code": describing your deployments declaratively by files (for example, Kubernetes manifests) stored in a Git repository.

In this tutorial, you create a CI/CD pipeline that automatically builds a container image from commited code, stores the image in Google Container Registry, updates a Kubernetes manifest in a Git repository and triggers a deployment to Kubernetes Engine using that manifest.

This tutorial uses two Git repositories: one for the application —the app repository— and one for storing the deployment manifests —the env repository. When a change is pushed to the application repository, tests are run, a container image is built and pushed to Container Registry. Once the image is pushed, the deployment manifests are updated to use that new image and they are pushed to the candidate branch of the env repository. This triggers the actual deployment in Kubernetes. Once the deployment is finished, the new manifests are copied over to the production branch of the env repository.

In the end, you have a system where: