Task -1 DevOps
Priyanshu Pathak
CKA and AWS_CSA intern at Linuxworld , DevOps and Cloud enthusiast
MY TASK OVERVIEW
JOB-1
- If Developer pushes to dev branch then Jenkins will fetch from dev and deploy on the dev-docker environment.
JOB-2
- If Developer pushes to master branch then Jenkins will fetch from master and deploy on master-docker 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 the dev-docker environment. If it is running fine then Jenkins will merge the dev branch to the master branch and trigger #job 2.
Basic tools required
- Redhat-8 Linux Enterprise
- Docker
- Github
- Jenkins
Getting start my project
First, you created my own HTTPD Image by using Dockerfile so that you can use it in my project.
My DockerFile
FROM centos RUN yum install java-11-openjdk.x86_64 -y RUN yum install git httpd -y EXPOSE 80 CMD /usr/sbin/httpd -DFOREGROUND
Name of Image:- httpd:v1
JOB-1
you have a repository in which one is a developer branch code and another one is the master branch code. The Master branch have one HTML file named as master.html and the developer branch have code named as dev.html
My Job-1 name is dev-docker-environment and I set the URL of GitHub repo and branch dev1.
I used Poll SCM build Trigger so Jenkins each time go to Github and check if any code updated in the dev1 branch then it pulls code and deploy into the dev-docker-environment for testing purpose and also expose it with port no. 8081.
JOB-2
My Job-2 name is master-docker-environment and I used the same configuration as Job-1. But the only difference is that Jenkins Deploy master branch code into the production environment and expose it with port no. 8082.
I used Build after other projects are build trigger as well as PollSCM into Job-2. This Job run can run two ways if Job-3 is stable and also if some changed done directly into the master branch (production system). What is the purpose of using this triggered ?? You will understand clearly in further explanation.
Code is successfully deployed by Jenkins into docker environment
The output of Job-1 and Job-2 into Redhat-8 VM where Docker is running.
Job-3
This Job is manually checked by the QA team if the website running properly in the dev-docker environment then Jenkins will merge the dev branch code into the master branch code and also triggered Job-2, so that is the reason why I set one more triggered inside Job2.
Setup the environment of Job-3
So it was all about How to set up the environment of Job-1, Job-2, and Job-3. Let's run all Jobs one by one.
Job-1 Output, when I uploaded code into dev1 branch on Github
Job-2 Output, when I uploaded code into the master branch directly on GitHub but in the real world, we rarely put our code directly into the production environment.
Job-3 Output, when Job-1 successfully deployed and working fine then merging the dev1 brach code into the production system (master-docker-environment).
testing after dev1 branch Code is deployed into master branch which has IP 172.17.0.3