DEVOPS(homework 2)

DEVOPS(homework 2)

Hello everyone this is my homework project for Devops assembly lines (sorry i am a bit late) this project is a integration of so many great technology and its main motive is full automation.

OBJECTIVE:-

 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 job 1, job 2, job 3 and job 4 using build pipeline plugin in Jenkins 

4. Job 1 : Pull the GitHub repo automatically when some developers push repo to GitHub.

5. Job 2 : By looking at the code or program file, Jenkins should automatically start the respective language interpreter install image container to deploy code ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed ).

6. Job 3 : Test your app if it is working or not.

7. Job 4 : if app is not working , then send email to developer with error messages.

8. Create One extra job job 5 for monitor : If container where app is running. fails due to any reason then this job should automatically start the container again.

SOLUTION:-

No alt text provided for this image
  1. As we can see our first task is very easy we just have create two docker image using dockerfile concepts I have created very basic images using centos as the base of it. I have install many software in them some are wget , java , jenkins , openssh-clients , httpd etc. we can install them as for our requirement and use cases mainly image that is going to host html pages must have its interpreter like html image will contain httpd which can resolve html pages.
  2. we will set the start of jenkins services in the build of the docker file so as soon as we run that container tha jenkins will start. We will use volumes as to mount them with our containers so we don't loose data and our management will be easy . The dockerfile image i have show it is not completed some things are missing in it and it about only one image.
  3. we are gonna use jenkins for full automation and our goal is that as soon as our developer push code to github the code will first go to testing environment and as soon as the QAT(Quality Assurance Team ) will give it green signals that code will get depolyed.
  4. Job1 is vary easy if u even know a bit about the jenkins so i have created code with respect to that I have mixed job1 and job2 so i have set an repository of git hub where our developer was pushing the code then then the jenkins will download the code and check for the type of the code if is will we html so it will launch the respective container and if the code is php it will launch that container which has php or more precisely it will use the image that have respective softwares. Then it will copy the data in tha respective attached volume .
No alt text provided for this image
sudo cp -f -v * data/
sudo  find data/  -type f -name "*.html" >  sudo cp -f -v *  /var/lib/docker/volumes/testing_os_html/_data
docker run -dit  -v testing_os_html:/var/www/html  --name html_web_os httpd
sudo  find data/  -type f -name "*.php" >  sudo cp -f -v *  /var/lib/docker/volumes/testing_os_php/_data
docker run -dit  -v testing_os_php:/var/www/html  --name html_web_php httpd-php

No alt text provided for this image

5.For my simplicity i have considered that if the container is running then it has passed the QAT test and if it is not running then it has failed the QAT test .But rather then using this we can use remote trigger and we can give the url to QAT team so as soon as they think the code is good to go., so they just use the url to run that job and then the code get deployed on the server.

if [[sudo docker ps | grep testing_os]] 
then
	exit 0
else
	exit 1
fi    
    

 6.So this is the second last job as we get the information from the previous or we use build triggers to automate so as soon as the the job2 pass with flying colors our this job the job3 will run automatically and it will launch the production os and that will be visible to clients .

No alt text provided for this image
sudo  find data/  -type f -name "*.html" >  sudo cp -f -v *  /var/lib/docker/volumes/production_os_html/_data
docker run -dit  -v production_os_html:/var/www/html  --name html_web_os_production httpd
sudo  find data/  -type f -name "*.php" >  sudo cp -f -v *  /var/lib/docker/volumes/production_os_php/_data
docker run -dit  -v production_os_php:/var/www/html  --name html_web_php_production httpd-php

  7.So this will we our last and final job i.e. job4 it will keep an eye on the production os as soon as it goes down it will give this information to our developer that will correct the problem occoured.

if [[sudo docker ps | grep html_web_os_production]] 
then
	exit 0
else
	exit 1
fi    
    

if [[sudo docker ps | grep php_web_os_production]] 
then
	exit 0
else
	exit 1
fi    
    

CONCLUSION:-

  • we have created a fully automated environment for our developer in which the developer just have to push remaining everything will be automated .
  • this shows the power to intregration and we can learn so much from it.


To view or add a comment, sign in

More articles by Vedansh Shrivastava

Others also viewed

Explore content categories