Jenkins With Kubernetes
Updated: Sep 1, 2020

In the previous articles of this series, we have looked upon how to set up jenkins, execute CI-CD pipelines, how to deploy a docker app with jenkins and now we are going to move one step forward and deploy app on kubernetes cluster.
Lab setup
Source Code : https://github.com/technoroots/kubernetes-app-deploy-jenkins.git
Use the below command to clone the repository
git clone https://github.com/technoroots/kubernetes-app-deploy-jenkins.git
We should already have a 3 node kubernetes cluster.

Jenkins server up and running on node1
Github credentials stored in jenkins
Dockerhub credentials stored in jenkins.
Execution
Install plugins in jenkins
For this login to jenkins console -- Go to Manage Jenkins -- Manage Plugins -- Go to available tab -- search and install kubernetes continuous deploy

Add kubernetes credentials
For this , Go to jenkins homepage -- Credentials -- Under Global section -- Add kubernetes credentials.( here we will copy paste the kubeconfig file)
This file will be under /$HOME/.kube/config

Configure a multibranch pipeleine
For this go to jenkins home page -- Click on New Item -- Create a multi branch pipeline -- Name it as train-app-kubernetes -- Give Branch source as Github and give the below repo URL and github credentials as well .
https://github.com/technoroots/kubernetes-app-deploy-jenkins.git

Run the pipeline
Now go to the project train-app-kubernetes and , go to the master branch and run the pipeline. It will take around 10 minutes to complete.

After the pipeline execution is done, login to the kubernetes master and execute the below command , we will see the pods are coming up.

Here we put and end to our series on jenkins tutorials. Hope you liked it.Stay tuned for more technical stuff.