Integrating Jenkins with Kubernetes

Ashutosh Kumar Sah
4 min readAug 5, 2020

--

DevOps task 3 by Vimal sir (Linux World ,India)

The project is for doing following steps :

  1. Create container image that’s has Jenkins installed using dockerfile Or You can use the Jenkins Server on RHEL 8/7

2. When we launch this image, it should automatically starts Jenkins service in the container.

3. Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins

4. Job1 : Pull the Github repo automatically when some developers push repo to Github.

5. Job2 :
1. By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code on top of Kubernetes ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed ).

2. Expose your pod so that testing team could perform the testing on the pod.

3. Make the data to remain persistent ( If server collects some data like logs, other user information ).

6. Job3 : Test your app if it is working or not.

7. Job4 : if app is not working , then send email to developer with error messages and redeploy the application after code is being edited by the developer

this i my github link for this task/project..

The above description is for doing the task/project 3.

Now what i have done is decribed below

***************************************************************

Here we are using the jenkins and github so code will be auto downloaded from github whenever any new code is appneded or pushed to github.

here what are we doing is a Kubernetes pod will be launched automatically & the code will be auto deployed. The pod will be exposed automatically

we are using the data which will be persistent as a dynamic PVC. and this will be attached. so that no data will be going lose if container Stopped working or maye be crashed some time.

Step 1: We have created a container image that has Jenkins installed using Dockerfile.

we have exposed Port 8080 because Jenkins runs on port 8080.

The command for making image is “docker build -t myname:mytag File-location” here file-location means where Dockerfile is saved.

Command for run container: docker run -it -p 2301:8080 — name ashu1 myname:mytag

Here we are Pulling from Git repo and building image

In this job we downloaded the code from github and copied it into base os and then into dockerfile to build image for testing.

Auto Detection of extension and launching container

This will detect the code and launch the respective

Testing

thanks vimal sir for teaching us so well that’s why we are able to the task…

this article will be updated soon… with more brief details..

--

--

Ashutosh Kumar Sah
Ashutosh Kumar Sah

Written by Ashutosh Kumar Sah

DevOps Engineer | Ex - Teqfocus | Microsoft Certified: Az-900, Ai -900, Dp-900 | 2x Oracle cloud infrastructure certified fundamental 2022 | Aviatrix certified

No responses yet