Kubernetes CI/CD using Jenkins on Google Cloud
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.
List of plugins you need in Jenkins .
- Google OAuth Credentials Plugin
- Docker Pipeline Plugin
- CloudBees Docker Build and Publish plugin
- GitHub Plugin
My friend Nilesh Suryavanshi has already written detail blog on how to push image to GCR container repository using Jenkins.
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 !!
If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇