Vanshita Mittal
4 min readJul 13, 2020

Finally , I completed Task 4 of DevOps Assembly Lines under the mentorship of Vimal Daga Sir .

TASK 4:

Create A dynamic Jenkins cluster and perform task-3 using the dynamic Jenkins cluster. Steps to proceed are:

1) Create a container image that has Linux and other basic configuration required to run Slave for Jenkins. ( example here we require kubectl to be configured )

2) When we launch the job it should automatically start the job on slave based on the label provided for a dynamic approach.

3) Create a job chain of job1 & job2 using the build pipeline plugin in Jenkins

4) Job1: a) Pull the Github repo automatically when some developers push the repo to Github and perform the following operations as:

b) Create the new image dynamically for the application and copy the application code into that corresponding docker image

c) Push that image to the docker hub (Public repository) ( Github code contain the application code and Dockerfile to create a new image )

5) Job2 ( Should be run on the dynamic slave of Jenkins configured with Kubernetes kubectl command): Launch the application on the top of Kubernetes cluster performing following operations:

a) If launching the first time then create a deployment of the pod using the image created in the previous job. Else if deployment already exists then do a rollout of the existing pod making zero downtime for the user.

b) If Application created the first time, then expose the application. Else don’t expose it.

STEPS :

  1. Create a Github repository, and initialize it. Add two files to this repository-Dockerfile and index.html

2. Create s Dockerfile to build an image that has Linux and other basic configuration required to run Slave for Jenkins.

All the certificates files and config file should be in same folder.

3. Build this image and Push it into DockerHub ….

docker build -t vanshita21/jenkins-slave-kub:v1 .
docker login
docker push vanshita21/jenkins-slave-kub:v1

4. To make changes to the docker. service file…

vi /usr/lib/systemd/system/docker.service

In it specify the -H tcp://0.0.0.0:4243 in order to configure slave on Jenkins.

5. open jenkins ….

6. To configure cloud ….

First install Docker , yet another docker plugins.

go to Manage Jenkins →Manage Nodes & Clouds →Configure Clouds

7. Now create Jobs …

Job1 :

a) Pull the Github repo automatically when some developers push the repo to Github and perform the following operations as:

b) Create the new image dynamically for the application and copy the application code into that corresponding docker image

c) Push that image to the docker hub (Public repository) ( Github code contain the application code and Dockerfile to create a new image )

Job2 :

( Should be run on the dynamic slave of Jenkins configured with Kubernetes kubectl command): Launch the application on the top of Kubernetes cluster performing following operations:

a) If launching the first time then create a deployment of the pod using the image created in the previous job. Else if deployment already exists then do a rollout of the existing pod making zero downtime for the user.

b) If Application created the first time, then expose the application. Else don’t expose it.

8. To see Build Pipeline view …

install build pipeline plugins .

Final View of the task ….

Thanks Vimal sir for this deep knowledge.

No responses yet