DevOps Assembly Lines Task #3

DevOps Assembly Lines Task #3

Task Description:

  1. Create container image that’s has Jenkins installed using docker file.
  2. When we launch this image, it should automatically starts Jenkins service in the container.
  3. Deploy a container of this image on top of Kubernetes where we use Kubernetes resources like Pods, ReplicaSet, Deployment, PVC and Service.
  4. Create a job chain of job 1, job2, job 3 and job 4 using build pipeline plugin in Jenkins 
  5.  Job 1: Pull the Github repo automatically when some developers push repo to Github.
  6. Job 2: By looking at the code or program file, Jenkins should automatically start the respective language interpreter installed image container to deploy code on top of Kubernetes ( eg. If code is of PHP, then Jenkins should start the container that has PHP already installed )
  7. Expose your pod so that testing team could perform the testing on the pod.
  8. Make the data to remain persistent ( If server collects some data like logs, other user information )
  9. Job 3: Test your app if it is working or not.
  10. Job 4: if app is not working , then send email to developer with error messages and redeploy the application after code is being edited by the developer.

Creating Jenkins image:

  • Create a text file named 'Dockerfile'.
No alt text provided for this image
  • Now to create an image with it:

>> docker build -t jenkinsimage:v1 ws/

Running Jenkins container on Kubernetes:

YAML code to create a container with jenkins running on port no. 8080:

No alt text provided for this image

Now to start the Jenkins container using this file:

>> kubectl apply -f jenkins_pod.yml

>> Kubectl get all

No alt text provided for this image

This will deploy the jenkins pod successfully.

Now to get the IP where the jenkins service is running:

>> minikube ip

Now, to use jenkins web UI use minkubeIP:port_no.

To get your jenkins password to use web UI:

>> kubectl logs pod_name

In the logs we'll find the jenkins password.

To proceed further we will need to install git, email extension build pipeline plugins in Jenkins.

Creating Repository on GitHub:

  • git clone https://github.com/suchitrasaksena/DevOps_task3.git

After creating the files:

  • git add .
  • git commit -m "first commit"
  • git push -u origin master
  • The repository will be created successfully.
No alt text provided for this image

The repository is successfully created.

Configuring Jenkins:

Job 1:

This job will automatically download the GitHub repository whenever developer pushes any changes.

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

Job 2:

This job will automatically run after successful completion of job 1 and start the apache pod to deploy the website.

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

YML file to create service for apache webserver:

No alt text provided for this image

YML file to create PVC for apache webserver:

No alt text provided for this image


YML file to create Deployment for apache webserver:

No alt text provided for this image


Job 3:

This job will run after successful completion of job 2 and will check if the deployed website has any errors.

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

Job 4:

This job will run after job 3 to notify the developer if the website has any errors via mail.

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

All the jobs execute successfully, here's the build Pipeline view:

No alt text provided for this image

The task is successfully completed, and the website is deployed successfully.

No alt text provided for this image

Thanks for reading, feel free to leave your suggestions to improve this setup.

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

Suchitra Saksena的更多文章

  • DevOps Assembly Lines Task #6

    DevOps Assembly Lines Task #6

    Task Description: Deploy your website on kubernetes with the help of Jenkins coding file as follows: 1. Create…

    2 条评论
  • DevOps Assembly Lines Task #5

    DevOps Assembly Lines Task #5

    Task Description: Integrate Prometheus and Grafana in following way: Deploy them as pods on top of Kubernetes using the…

    4 条评论
  • DevOps Assembly Lines Task #4

    DevOps Assembly Lines Task #4

    Task Description: Create A dynamic Jenkins cluster to achieve this setup: Create container image that’s has Linux and…

  • DevOps Assesmbly Lines Task #2

    DevOps Assesmbly Lines Task #2

    Task Discription: Create container image that has Jenkins installed using dockerfile. When we launch this image, it…

  • DevOps Assembly Lines Task #1

    DevOps Assembly Lines Task #1

    Task Description : JOB 1 If Developer push to master branch then Jenkins will fetch from master and deploy on "Deploy"…

    4 条评论

社区洞察

其他会员也浏览了