DevOps Automation done with GitHub, Jenkins and Kubernetes

DevOps Automation done with GitHub, Jenkins and Kubernetes


?Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows.Jenkins is a free and open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. It is a server-based system that runs in servlet containers such as Apache Tomcat.

Kubernetes (commonly stylized as k8s) is an open-source container-orchestration system for automating computer application deployment, scaling, and management. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation. It aims to provide a “platform for automating deployment, scaling, and operations of application containers across clusters of hosts”.

I have complete a DevOps Task in which I have deployed the Website on Apache Web server or codes written in PHP on PHP server using Jenkins over the Kubernetes container management platform. For deploying these kind of server I have used the Docker images and also create my own Docker image that will provide complete environment in single OS.

In the Docker image which I have created already configured the admin and installed some plugins that will need in performing the task. You get all resources for this task by visiting the links provided below.

Steps to be followed for the task:

Step 1: Create container image that’s has Jenkins installed using Docker file Or You can use the Jenkins Server on RHEL 8/7

Step 2: When we launch this image, it should automatically starts Jenkins service in the container.

Step 3: Create a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins

Step 4: Job1 : Pull the GitHub repository automatically when some developers push repository to GitHub.

Step 5: Contains multiple job steps

Job2 :

   1. 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 )

   2. Expose your pod so that testing team could perform the testing on the pod

   3. Make the data to remain persistent ( If server collects some data like logs, other user information )

Step 6: Job3 : Test your app if it is working or not.

Step 7: Job4 : 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.

Enough theory done. Now its time to action!!!!

Step by step procedure and explanation:

Step 1: Created one container image that’s has Jenkins and Kubernetes installed using Docker file.

No alt text provided for this image

Codes for creating the docker image

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

Image build successfully

Step 2: When we launch this image, it should automatically starts Jenkins service in the container.

No alt text provided for this image

codes for deploying this created image on Kubernetes engine. Here I have created a deployment code with NodePort service

Step 3: This is a job chain of job1, job2, job3 and job4 using build pipeline plugin in Jenkins.

No alt text provided for this image

Step 4: Job1 : Developer push codes to the GitHub repository

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

Job that pull the GitHub repository automatically

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

Output for the successful pull of GitHub repository

Step 5: Job2 : Jenkins launch pod automatically by looking at the program file on top of Kubernetes.

No alt text provided for this image

this job is triggered by Job1

No alt text provided for this image

Looking for coding files

No alt text provided for this image

Successfully pod launch as per coding files. Here the pod having the persistent storage and exposed for outside world.

Step 6: Job3 : Testing whether pods working or not.

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

this job is triggered by job 2

No alt text provided for this image

Output for the testing of pods

Step 7: Job4: for testing the web server or app running on the pod

No alt text provided for this image

this job is triggered by job3

No alt text provided for this image

this code is for testing the website running or not

No alt text provided for this image

email notification send when some error occur in testing or in coding file

No alt text provided for this image

Output for the website testing

Job5: for container relaunch if any error occur

No alt text provided for this image

job5 is triggered by job4

No alt text provided for this image

codes for testing the pod and relaunch if error found

No alt text provided for this image

Output for pod relaunching

No alt text provided for this image

this is output obtained by Build Pipeline after the successful completion of all jobs

No alt text provided for this image

this is the output found when we visit to the url obtained when we run these code snippet

minikube service web-service --url

https://192.168.99.100:30301

Setting up email notification:

No alt text provided for this image

email received when pod fails or any error occur:

No alt text provided for this image

Codes for launching pod as deployment :

No alt text provided for this image

this code launches the web server, it has persistent storage for coding file and exposed at port 30301 for outside world.

I am highly greatful to my mentor " Mr. Vimal Daga " who teaches me these good technologies in right way and as a result this is completed successfully.

For code files and Docker file visit my GitHub profile:

For Docker image visit to my Docker Hub profile:

!!! Thanks for reading this article !!!



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

Manish Verma的更多文章

社区洞察

其他会员也浏览了