#Task-2 Mlops+DevOps: CI/CD
What is Machine Learning?
- It is the study of various activities going around and making our machines smarter and to this much extent that they can try to think like human beings and therefore we are trying to build an application or method which can train machines how to learn.
- We are do this not just for fun but, there's a great reason i.e. make use of their high speed and efficiency when it comes to numbers and memory based problem ,a normal human can have error but machines will hardly give any error in this field of science and technology.
What is DevOps?
- DevOps is the set of practices ,which if one follows, he/she will be able to achieve automation.
Why this task ?
- Because in today's agile and fast growing world if we need to keep up with others going on with faster approach, we need automation as much as possible.
What the project is About ?
The motto of this project is like ,when a developer sends a code to a repository, jenkins automatically start a CI/CD pipeline inorder to deploy the code completely to the webserver of operation's them and under which code will be checked by making use of status. Or maybe operator guys can also redirect this code to their QA team and deploy into testing environment if they want.
Project Description:
1. Create container image that’s has Jenkins installed using dockerfile
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 pliugin in Jenkins
4. Job1 : Pull the Github repo automatically when some developers push repo to Github.
5. Job2 : By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed ).
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.
8. Create One extra job job5 for monitor : If container where app is running. fails due to any reson then this job should automatically start the container again.
PreRequisites:
- Basic knowledge of Redhat or any other Linux OS
- Basics of Docker
- Good knowledge in Jenkins
- Some Networking Concepts
- A little bit knowledge on web servers , their creation and Deployment
So lets get started.........
First of all lets create a Dockerfile for Running all of our codes in jenkins into a docker environment because it's always great to manage every different environment by making use of jenkins
For this I'll be doing all my stuffs inside a directory /root/devops_task2
Here is the screenshot of Dockerfile for jenkins
After that just Run the following command to create the image for jenkins
docker build -t ssjnmjenkins:v1 /root/devops_task2
Now to start the docker container for jenkins using the command in the screenshot
Now that I have started my jenkins and I have to used DNAT protocol on port no. 8081 from 8080 so, when I'll be using my microsoft edge to connect to jenkins server and they will also ask for admin password which , we can get through command line or directly inside the image
This is very interesting now , that our jenkins is running inside a docker image :)
So, Lets download some plugins that we will be needing for the intrication Project
After all this is Over ,what I want is a slave node for jenkins that will help me to connect to the rhel 8 system on which my docker is running.
This the most critical step since every task is performed in this node "redhat_node" only because they are the one running with docker server which we will need in future to launch another dokcer on site .
So Got to Manage Node and Clouds
Here create an agent node for redhat_node
And then Configure this node according to the IP address and pass word for your main OS rhel 8 system
Give the credentials for SSH and One thing to be noted Here we will be using SSH to launch agents Do we must have a plugin named build SSH agent plugin
Finally we here are starting with our devops_task_job1
and here's the code for job1
- If we will look closely here , then I have searched for presence of html or php codes in our working directory and
- Secondly, I have used if and else statements inorder to check whether repository contains php , html or both codes.
Now the Important thing to notice here is that we will restrict the usage of nodes and asked all of tasks to be performed by redhat node
Then here is the code for checking the status of php/html site bu making use of apache monitoring data and saving it into variables named status_html and status_php
The Last thing that we need now is a smtp server to send emails to different sites where we will using a smpt server for gmail and using gmail's two-way security scheme, we can generated a code for any app the we want to be inked with gmail
But inorder to run these , we will need a plugin so lets install it
Then here is the configuration for my smtp server
Finally the code for job2 is like this and under the recipients we will add an email Id to get notified, here I will add my emailID to get to work
The project is ready now and let me add both of my jobs into build pipeline to try the code
We can also check the sites whether they are working or not
This means my code is fine and everything's working great as planned :)
And here is the previous output of emails when I was testing
And here is the latest email that describes task is stable now
And That's how CI/CD works ...........