Task 2
In this task of mlops training I am going create a complete Jenkins Pipeline from pulling the code from github, creating the suitable build environment, building the package till testing the code. I will represent the whole workflow of the task.
Pre-requisites: RHEL8 or Centos8 as base operating system, installed docker services.
First of all we will create a docker image with jenkins configured in it using Dockerfile. As soon as we run this docker image our jenkins service starts in it. Below is the Dockerfile I created to build the image.
Now we will build the image and run it. But while running the image, do not forget to expose port 8080 of the image as jenkins run on port 8080 by default. Now when you build the image your o/p at the console should be like as follows.
You will also gwt the initial admin password at console which will be used later. Now in you web browser access the port XXXX of your (here XXXX is the port number that you have assigned to port 8080 of jenkins container image which in my case is 5000). It will get us to the first login page of jenkins where the initial admin password will be used.
Now comes the part of jenkins. Here I will create 5 jobs as follows.
Job1: The task of this job is to pull the Github repo automatically when some developers push repo to Github. Here the role of build trigger and github webhook comes in play. This job will also create a directory named "webcode" in the local host.
Job2: This job will do an interesting work. By looking at the code or program file,this Jenkins job will automatically start the respective language interpreter install image container to deploy code. In this task I am taking PHP code as example, i.e., if code is of PHP, then Jenkins will start the container that has PHP already installed and start deploying the code. This job will be automatically triggered by job1.
Job3: This job is ment for testing the the app if it is working or not. This job will also be automatically triggered by Job3.
Job4: If the application in the deployment environment is not working then it will send an error notification to the developes via email. But we need to configure jenkins for sending emails.
Job4 is triggered by Job3:
We will also create an additional job say Job5 which will keep on checking if container image in which the application is deployed is working or not. And if nit working then it will relaunch that container image. It will keep on checking the running container at every 5th second.
We used Jenkins build pipeline to do all the job chaining so lets install the pipeline plugin and have a look at that.
This is the overall view the workflow of task assigned to me in my MLOps training.
Thank you for having a look at this and feel free to contact in case of any querry.