Marek Bartík
Marek Bartík
Creator of this blog.
Feb 26, 2018 2 min read

Google Kubernetes Engine + Cloud Builder + GitHub for easy and quick CD pipeline

I love Google Cloud Platform. I love Google Kubernetes Engine. And I love GitHub as well. But I need a quick CD pipeline for an easy automated app deployment. Setting up the whole Jenkins CI or using some paid Pipeline as a service takes too much time, energy and money. Here comes the Google Cloud Builder (currently beta).

Let's start

I have an easy stateless php app running on nginx and php-fpm in Docker containers versioned in git on GitHub. And I need is to deploy it quickly and cheap to GKE.

Open up Build triggers. It should be in Google console — Tools — Container Registry — Build triggers (but, you know, they change the UI like every week, so it might be somewhere else) image

Link your GitHub account with GCP image

Import your repo image

Set the trigger image

Choose the cloudbuild.yaml where you can define your CI/CD pipeline as a code.

Let's test it

It is ugly, I know. I needed a fast solution, not a pretty one.

I need to build two Docker images, from different Dockerfiles, push them to Google Container Registry, template kubernetes deployment manifests, deploy them on GKE (kubectl apply) and create an ingress resource for external http traffic.

After I push to the repo, the build is automatically started image

I see the git commit and action which caused the trigger, pipeline steps, time they took, total time of the build, link to images in GCR. And log: image


All is immutable, I can easily rollback deployment to a tagged image with a commit id from git. I can Rebuild the build in Build history. Ingress DNS records are pushed to CloudFlare automatically.

I had to create my own deployment/service/ingress/whatever kubernetes manifests and had to template them with sed (which is super ugly and the syntax won’t always work). Google Cloud Builder is in beta and there is definitely a lot to improve. Templating and GKE integration would be nice (manual kubectl apply, srsly?) to have. As well as deployment strategy selection and easier provisioning maybe?

Check the source repo:

EDIT: Check this amazing github repo of the one and only Kelsey Hightower with great tutorials on Google Cloud Builder