DevOps Assembly Lines Task #4

DevOps Assembly Lines Task #4

Task Description:

Create A dynamic Jenkins cluster to achieve this setup:

  1. Create container image that’s has Linux and other basic configuration required to run Slave for Jenkins. ( example here we require kubectl to be configured )
  2. When we launch the job it should automatically starts job on slave based on the label provided for dynamic approach.
  3. Create a job chain of job 1 & job 2 using build pipeline plugin in Jenkins:
  • Job 1: Pull the GitHub repository automatically when some developers push repo to GitHub and perform the following operations as:
  1. Job 1: Pull the GitHub repository automatically when some developers push repo to GitHub and perform the following operations as:
  2. Job 2: ( Should be run on the dynamic slave of Jenkins configured with Kubernetes kubectl command): Launch the application on the top of Kubernetes cluster performing following operations:
  • Job 2: ( Should be run on the dynamic slave of Jenkins configured with Kubernetes kubectl command): Launch the application on the top of Kubernetes cluster performing following operations:
  1. If launching first time then create a deployment of the pod using the image created in the previous job. Else if deployment already exists then do roll out of the existing pod making zero downtime for the user.
  2. If Application created first time, then Expose the application. Else don’t expose it.

Creating Repository on Github:

Commands:

No alt text provided for this image

Index.html file:

No alt text provided for this image

Dockerfile:

No alt text provided for this image

The repository will be created successfully.

Setup in Linux Environment:

  • setenforce 0
  • systemctl stop firewall
  • systemctl start Docker
  • systemctl start httpd
  • systemctl start Jenkins

Creating image with kubectl configured:

Docker file to create the image:

No alt text provided for this image

Now to create an image using this Docker file:

>> docker build -t kubernetes-env:v1 ws/

Image will be created successfully created.

Configuring Jenkins:

Job 1:

This job will download the repository from GitHub whenever developer pushes some changes to the repository and will check for html files and then it will build the required image for the code using the docker file from the repository.

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 is the downstream of job 1 and after successful execution of job 1 this job will start the deployment of the website if the deployment is not already running or else it will roll the new update on the already running containers.

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

Both the jobs run successfully and the website is deployed successfully.

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

The task is complete!

Thanks for reading, do leave your reviews and 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 #3

    DevOps Assembly Lines Task #3

    Task Description: Create container image that’s has Jenkins installed using docker file. When we launch this image, it…

  • 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 条评论

社区洞察

其他会员也浏览了