Mlops Task- 1
Git
Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows
Jenkins
Jenkins is a free and open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery.
Plugins are the primary means of enhancing the functionality of a Jenkins environment to suit organization- or user-specific needs. There are over a thousand different plugins which can be installed on a Jenkins master and to integrate various build tools, cloud providers, analysis tools, and much more.
Docker
Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels
Problem Statement
❗️TASK-1 ❗️
JOB#1
If Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.
JOB#2
If Developer push to master branch then Jenkins will fetch from master and deploy on master-docke environment.
both dev-docker and master-docker environment are on different docker containers.
JOB#3
Manually the QA team will check (test) for the website running in dev-docker environment. If it is running fine then Jenkins will merge the dev branch to master branch and trigger #job 2
Let Start with the Task
Prerequisite
- Git
- GitHub
- Jenkins Sever
- Docker Install
- Apache Web Server running on RHEL-8
In this project we are Using RHEL-8 where Jenkins and Docker are in running state
lets create one Workspace where git is running , In my case in my Windows system
Create Repository using $ git init command
Create Web page
put web Page to staging area so it keep track
$ git add task1.html
To put in Commit Area to do Roll back
$ git commit task1.html -m “first comment”
Before that create one Repository in GitHub
Give the path and push your Code to gitHub
Here the issue is Developer push there Code manually But we want Automation So Set hooks , As soon as developer commit it will Automatically push to GitHub
So set Hooks in Git, Go to
$ notepad .git/hooks/post-commit
Now whenever developer do any change in code and commit it will auto push to git Hub
Now our code is in GitHub we want to Deploy our code or website to webServer
2 way Available
- Manually
Someone download the code and run the copy the code to configuration file of server and run it
- Automation
For Automation We use Jenkins , So start your Jenkins server with port :8080
After starting Jenkins Server create one job
As Jenkins is just A tool and its power come from plugins , here we require Git plugin which help us to do automation So install git Plugins and git your GitHub Repository link
Now whenever developer commit it will auto push the code to GitHub and due to Jenkins its come to Jenkins workspace
Now open Jenkins shell and write Command which will copy or deploy your code to Apache web Server running on Rhel-8
$ cp index.html /var/www/html
It will Copy your Code and web Server Start But the issue is operational Team keep on eye on gitHub if any changement done So we again want Automation
We use Triggers in Jenkins , Various Triggers are Available in Jenkins But we use Build Trigger as developer commit , one click complete Automation
In build trigger we have to set token and provide the token to git Hooks
One Click Complete Automation
But the only hard thing is Environment where webServer is running
Now Here we integrate this project with Docker
Docker
Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels
As docker in Running on Rhel-8 , So we pull the image from docker hub which provide complete Environment where Apache Web Server is running
# docker pull httpd
Now integrate docker with Jenkins
JOB#1
If Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment
Create one Developer branch
JOB#2
If Developer push to master branch then Jenkins will fetch from master and deploy on master-docke environment.
JOB#3
Manually the QA team will check (test) for the website running in dev-docker environment. If it is running fine then Jenkins will merge the dev branch to master branch and trigger #job 2
this is complete One click Automation using Git Git-Hub , Jenkins , Docker
Thank You
Any Query or Suggestion feel free to ask
linkedin : linkedin.com/in/aditya-kumar-soni-91370b189