MLOPS : Task 1

❗️TASK-1 ❗️

Create a Job Chain:

If Developer pushes to dev branch then Jenkins will fetch data from dev branch and deploy on the dev-docker environment.

If Developer pushes to the master branch then Jenkins will fetch from the master branch and deploy on the master-docker environment.
Both dev-docker and master-docker environments are in different docker containers.

Manually the QA team will check (test) for the website running in the dev-docker environment. If it is running fine then Jenkins will merge the dev branch to master branch and trigger #job 2

Tools and Technologies used:

  1. Git and GitHub
  2. Docker
  3. Jenkins
  4. RHEL-8 OS in Virtual Machine
  5. Base OS: Windows 10

Setup environment on windows:
(I) First install git on windows from here: Git-Downloads
(II) Create a GitHub account if you don’t have it.

Check for git version by typing :

$ git — version
git version

Create a hook to automate git push i.e. as soon as developer commit the version in GitHub also get updated:

cat >> .git/hooks/post-commit
git push

Configure yum in RHEL-8(GUI):
#cd /etc/yum.repos.d/
#cat >> rohit.repo


#cat >> docker.repo


#cat >> jenkins.repo


Setup environment on RHEL-8:

# yum install java-11-openjdk.x86_64 -y
# yum install jenkins
# yum install git
# setenforce 0
# systemctl stop firewalld
# systemctl start docker
# systemctl start httpd
# systemctl start jenkins

Start the Jenkins and download some plugins for git & docker.
If you are starting Jenkins for the first time you need the password which is stored in /var/lib/jenkins/secrets/initialAdminPassword .
You can change your password after navigating to Manage Jenkins — Manage Users.

Setup a Docker environment:

# yum install docker-ce --nobest
# systemctl start docker
You can clean your environment with the command below(Warning: It will delete all your containers):
# docker rm -f $(docker ps -a -q)
We are going to launch a website on a httpd server so we require an httpd image of docker to launch a container from it.# docker pull httpdRun two containers one for developer and testing and other for production environment and mount their volumes with the base operating system(In our case that is RHEL-8). Mounting is done because the data in container is ephemeral that is, as soon as our container goes down due to any reason all our data is lost.
Httpd image stores webpages in /usr/local/apache2/htdocs by default so we mount it to our base OS directory.
We use -v flag to mount while launching container.

We are creating two containers:
1) devoshw: for the testing purpose used by developers(dev branch) and testing team(in our case that is also Jenkins), mounted on /root/hwdev.
2) masteroshw: for the production purpose used by master branch, mounted on /root/hwmaster.

Create Job1 on Jenkins:

Create Job2 on Jenkins:

Create Job3 on Jenkins:

View my work on GitHub.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rohit Mittal

Rohit Mittal

I am an enthusiastic engineer, seeking an opportunity where I can explore, evolve, learn and at same time contribute to the goals of an organization.