DevOps Task-2

DevOps Task-2

Tasks :

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 plugin 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 install 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.

Solution:

So we will start by creating a Dockerfile using centos: 7 image pulled from docker hub.

No alt text provided for this image

FROM: the image to be used for container

RUN: commands to be executed while building the modified container

We will be installing wget for downloading the files from url, and before moving further we will set up the yum repository for Jenkins from URLs using wget command. Then we will first install java as it is a prerequisite for the smooth functioning of Jenkins. We will make a Jenkins entry in the sudoers file to give it root powers without the requirement for any password. We will also require Git installed to be used in Jenkins as a plugin. Python3 is installed for a mailing code that will be used later in a job.

**The email part can be done directly from Jenkins plugins as well. I have used python here. If anyone needs the Jenkins method, I will make a separate article for it.

COPY: command will be used to copy files from host to image while building it.

CMD: the cmd used here will keep the Jenkins live till the container is on and will start on container boot.

Php webserver creating a Dockerfile using centos: 7 image pulled from docker hub.

No alt text provided for this image


and the mail.py file :

No alt text provided for this image

Run the Command to install image of your Dockerfile.

docker build -t jenkins:latest  /root/ws
docker build -t my-php-server:latest  /root/ws1

On successful build, you will see a screen like this.

No alt text provided for this image

Now See the below image this two images is install in your os.

No alt text provided for this image

Now we will run our container.

docker run -it --privileged --name jenk -p 8081:80 -v /:/host jenkins:latest

--privileged has been used for special access to be used later while playing with dockers.

-v: the mount seen here has been done for the same as well.

No alt text provided for this image
No alt text provided for this image

Now we will be moving on to our jobs.

First job :

No alt text provided for this image
No alt text provided for this image

Next Job :

No alt text provided for this image

This will be triggered as soon as Job1 completes and will deploy a container on the host system.

I have put one condition of normal HTML server & PHP Server conditions can be added accordingly added as per the extensions and container images can be run on those cases.

See the terminal containers is running..

No alt text provided for this image

Job 3 is to test our application.

No alt text provided for this image

Job3 will be successfully run so the next job send mail to the dev.

Job4 :

No alt text provided for this image

Now time for the last one, the monitoring job. This is set to check every minute for the status of the container.

No alt text provided for this image

Now Build Pipeline:

No alt text provided for this image
No alt text provided for this image

All is the done using DevOps Automation so see the production site of the client access this

Html pages Apache Server

No alt text provided for this image

Php pages Apache Server

No alt text provided for this image

So this is all jobs are working good thanks.

For any queries, issue or suggestion, please feel free to contact me anytime. I will respond as soon as possible.

Vivek Saini

DevSecOps Consultant | Specialization in DevOps Cloud & Containers

4 å¹´

great buddy

Aditya Joardar

Staff Software Engineer @ Botsync | Driving Automation for Future Industries with Graph-Based Solutions

4 å¹´

thanks for your posts on devops..... these are amazing

要查看或添加评论,请登录

Tushar Dighe的更多文章

  • Enhancing Cloud Security with Wiz: A Game-Changer for DevOps and Security Teams

    Enhancing Cloud Security with Wiz: A Game-Changer for DevOps and Security Teams

    Enhancing Cloud Security with Wiz: A Game-Changer for DevOps and Security Teams In today's fast-paced cloud…

  • AWS : NASA Case Study

    AWS : NASA Case Study

    Established in 1958, the National Aeronautics and Space Administration (NASA) has been working around the world—and off…

  • The World of “Big Data”

    The World of “Big Data”

    What is data? The quantities, characters, or symbols on which operations are performed by a computer, which may be…

  • ?? Hybrid Multi Cloud Task-3??

    ?? Hybrid Multi Cloud Task-3??

    INTEGRATION OF WORDPRESS RUNNING ON TOP OF KUBERNETES CLUSTER WITH AWS RDS.?? So, you might be thinking that what is…

    2 条评论
  • ?? Hybrid Multi Cloud Task-2??

    ?? Hybrid Multi Cloud Task-2??

    Using EFS service with Terraform. Objective: Perform the task-1 using EFS instead of EBS service on the AWS as…

  • ?? Hybrid Multi Cloud Task-1??

    ?? Hybrid Multi Cloud Task-1??

    To launch Webserver with AWS using Terraform code Steps required to launch the App using terraform:- 1. Create the key…

  • ?? Ansible Task-2??

    ?? Ansible Task-2??

    Deploying Web Server on AWS through ANSIBLE! TASK DESCRIPTION: ?? Provision EC2 instance through ansible. ?? Retrieve…

  • ?? DevOps Task-6 ??

    ?? DevOps Task-6 ??

    Integration of Jenkins with Kubernetes using groovy What is Groovy? Groovy is a Java-syntax-compatible object-oriented…

  • ?? DevOps Task-5 ??

    ?? DevOps Task-5 ??

    Deploy prometheus and grafana on the top of kubernetes . Tasks : Integrate Prometheus and Grafana and perform in…

  • ?? DevOps Task-4 ??

    ?? DevOps Task-4 ??

    In this article i have created a fully automated CI/CD build pipeline by using the technology git, github, Jenkins…

社区洞察

其他会员也浏览了