DEVOPS TASK 3??
JENKINS ?INTEGRATION  WITH ?
KUBERNETES??

DEVOPS TASK 3 JENKINS INTEGRATION WITH KUBERNETES

Hello Guys back with another article. In this article you will find jenkins intergration with Kubernetes.

What is Kubernetes ?

Kubernetes is an open-source container-orchestration system for automating application deployment, scaling, and management. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation . In simple words, it's a management tool for container technology like docker, podman, CRI-O etc. We have some other orchestration tools like Swarm(by docker) etc, but kubernetes gives more flexibility in managing container with it's resources.

Task Description:

1. Create container image that’s has Jenkins installed using dockerfile Or You can use the Jenkins Server on RHEL 8/7

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 :

   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 )

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 and redeploy the application after code is being edited by the developer .

Task Requirement --> we have installed minikube, which install a virtual machine which has kubernetes Installed.

No alt text provided for this image

Now your kubernetes cluster has been started, now you need another vm, I've use rhel 8. Here we're using docker to launch our kubectl client and jenkins server, for which we have created image using Dockerfile, as:

No alt text provided for this image
docker build -t my_jenkins /jenkins_docker/.

The above command will create a dockerimage. After that you need to make a cofig file inside /root/./kube/config.

No alt text provided for this image

After that do configuration in below file.

vim /usr/lib/systemd/system/docker.service

after that reatrt tocker and reload daemon


systemctl daemon-reload

systemctl restart docker
No alt text provided for this image

Then we have to create a dockerfile of jenkins.

No alt text provided for this image
docker build -t jenkins_server:2 /jenkins_docker/.         ----> create image

docker run -dit -v /jenkins_ws:/jenkins_ws -p 8080:8080 -e 
DOCKER_HOST=192.168.99.104:4243 --name jenkins_portal jenkins_server:2-->create OS

Now, we'll install some plugins in jenkins,

  1. Git plugin .
  2. GitHub plugin .
  3. Build pipeline plugin .

Now we've everything to start our practical, So let's begin with steps to configure deployment with CI/CD and Kubernetes . Open Jenkins and follow along,

Step 1:

Job 1 : This job will pull code from GitHub :

No alt text provided for this image

Step 2:

Job 2:- This job will detect code, either php or html and run kubectl client container with image created before and run Kubernetes pod with required interpreter .

No alt text provided for this image

Step 3:

Job 3:- this job will simply check the http status code of website , checks if environment is running or not .

No alt text provided for this image


No alt text provided for this image

Yay !! We have done with task 3.

Github Link: https://github.com/amit17133129/DEVOPSTask3/tree/master

I hope you will find this article interesting !!

ThankYou!

Raghav Tiwari

___________________________

4 年

Great work buddy

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

Amit Sharma的更多文章

社区洞察

其他会员也浏览了