Project Description:

1. Create a job chain of Job 1, Job 2, Job 3 and Job 4 using build pipeline plugin in Jenkins

2. Job 1: Pull the Github repo automatically when some developers push the repo to Github.

3. Job 2 :

  • 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 )
  • Expose your pod so that testing team could perform the testing on the pod
  • Make the data to remain persistent ( If server collects some data like logs, other user information )

4. Job 3: Test your app if it is working or not.

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

Pre-requisites for the practical :

  1. Git Installed on Your System
  2. A Github Repository should be there to commit the code or cloned in the local system.
  3. Create a post-commit hook in .git/hooks folder in Git for git push so that if a developer commits code then it automatically pushes to Github.
  4. Configure Kubernetes in your Rhel OS.
  5. Configure Jenkins in your Rhel OS.

**Note: **Preferably, Perform the tasks on Linux Machine for smooth functioning and seamless installations ( I am using RHEL-8).

Stepwise Implementation:

STEP 0: Load your Jenkins server and restart the services

$ systemctl restart jenkins

STEP 1: Create a job chain of Job 1, Job 2, Job 3 and Job 4 using build pipeline plugin in Jenkins

Install Build plugin in Jenkins by going to Manage Jenkins → Manage plugins → Available → Search for build plugin, install and restart

Image for post

STEP 2: Create Job 1 which will pull the Github repo automatically when some developers push the repo to Github.

  1. Select SCM as Git and provide the URL of GitHub repo which will help this job to pull the code from GitHub repo

Image for post

2. In Build Trigger, select GitHub hook trigger which makes the job pull the code only when there are some changes made in GitHub repo

Image for post

3. In Build, select Execute shell to perform following commands which will create a directory in the container and copy all the files from the GitHub repo to this directory

Image for post

STEP 3: Create a Job 2 which by looking at the code or program file automatically start the respective language interpreter installed image container to deploy code on top of Kubernetes

  1. In Build Triggers, select Build after other projects are built and write the name of job1 which makes the job2 to run only if job1 ran successfully

Image for post

2. In Build, select Execute shell for performing this script which will automatically start the respective language interpreter installed image container to deploy code on top of Kubernetes with persistent storage and also exposing the pod for testing

#jenkins #automation #kubernetes #web-server #devops

Automating Kubernetes With Jenkins
1.05 GEEK