Kubernetes CI/CD using Jenkins on Google Cloud

Manoj Bhagwat
AVM Consulting Blog
2 min readJun 29, 2019
Deployment pipeline.

This is our new blog and its about setting up CI/CD pipeline for Kubernetes using Jenkins in Google Cloud .

Sample code GitHub link . This is simple python application with backend PostgreSQL as database. This is just sample code we use this as reference and later you guys can modify same for your code. In repository we have Dockerfile and Kube YAML scripts as part of main application code/logic.

Jenkins server is setup in Google cloud on compute instance .

We need below things to be installed on instance for this POC.

  1. Jenkins
  2. Docker
  3. Gcloud CLI
  4. Git
  5. Kubectl

List of plugins you need in Jenkins .

  1. Google OAuth Credentials Plugin
  2. Docker Pipeline Plugin
  3. CloudBees Docker Build and Publish plugin
  4. GitHub Plugin

My friend Nilesh Suryavanshi has already written detail blog on how to push image to GCR container repository using Jenkins.

Cloudbees plugin to push image to repo.

So now we are able to pull the code and push image to GCR repository.

Next is we need to deploy these images to Kubernetes cluster running on Google Cloud . Will use kubectl cli to deploy images to K8s cluster .

In order for kubectl to authenticate with Kubernetes cluster we will need credentials and will fetch it using GCLOUD CLI .

I have written shell script that will do all this magic in Jenkins during CI/CD.

We haven't hard-coded docker image name inside YAML files , its just we are replacing value on run-time .

Hope this blog helps you guys, next blog will be about Kubernetes CI/CD using Helm Charts.

Meanwhile you can go through my another blog Understanding Helm Charts.

👋 Join us today !!

️Follow us on LinkedIn, Twitter, Facebook, and Instagram

If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇

--

--

Manoj Bhagwat
AVM Consulting Blog

Trying new things. Breaking stuff. Likes open source | DevOps | Find me on LinkedIn 🔎. https://www.linkedin.com/in/manoj-bhagwat-73045082/