Automation of Kubernetes with Jenkins and docker using jenkins image

Automation of Kubernetes with Jenkins and docker using jenkins image

what is Kubernetes?

Kubernetes (also known as k8s ) is an open source container orchestration platform that automates many of the manual processes involved in deploying, managing, and scaling containerized applications.

In other words, you can cluster together groups of hosts running Linux containers, and Kubernetes helps you easily and efficiently manage those clusters.

PROBLEM STATEMENT:

 Perform this task on top of Kubernetes, where we use Kubernetes resources like Pods, ReplicaSet, Deployment, PVC, and Service.

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

No alt text provided for this image


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

How to build Dockerfile?

docker build -t <image_name> <Dockerfile_directory>

ex- docker build -it kubernetes:1.0 /root/mydockerfile

Now we have to launch the image

docker run -dit -p 9090:8080 --name kube -v /root/ymlfiles:/host -v /root/kubeconf:/root/.kube 


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

No alt text provided for this image


Job1 :

Pull the Github repo automatically when some developers push repo to Github.

Job2 :

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

Expose your pod so that testing team could perform the testing on the pod C) Make the data to remain persistent ( If server collects some data like logs, other user information )

Job3 :

Test your app if it is working or not.

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.


Job1 :

Pull the Github repo automatically when some developers push repo to Github.

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


Job2 :

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 )

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

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

No alt text provided for this image

Add these commands in Excute Shell option in jenkins job which will create deployment.

No alt text provided for this image

yml file for crating deployment & PVC for applications file having .html extension

No alt text provided for this image

 Deployment of html

Here is my Job2 Output

No alt text provided for this image

Here in the above services like pv,pvc and deployment has been created in k8s

Job3 :

Test your app if it is working or not.

No alt text provided for this image

We need to generate app password for sending the mail

No alt text provided for this image

If this job will be fail then it wail send email to developer .

No alt text provided for this image

After see this emai, developer debug the code , again commit it , then again It will be pushed to GitHub & again there will be redeployment of application inside k8s pods , for that w eanalso use: 

  • deployment strategies in k8s like rolling-updates for roll-out , roll-in concept.

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.

No alt text provided for this image

The final web-application running inside k8s pods(html file)

No alt text provided for this image







Krishna Sharma

Apigee API Developer|API Management|Kong API Gateway|Kubernetes Certified|Microsoft Azure|DevOps

4 年

Sure...!!! I will help you as much as i can :)

回复
Ramandeep Singh

Associate Tech Lead - DevOps || AWS || Azure || GCP || Linux || Terraform || Jenkins || Docker || CI/CD || Kubernates || AWSCodepipeline ,Azure devops

4 年

I want to learn CI/CD and k8s, Jenkins.. Can you please help me out?

回复

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

Krishna Sharma的更多文章

  • Integration of ML and devops

    Integration of ML and devops

    Tweak of mlops model of cnn by using transfer learning and integrate with the DevOps automation Knowlege of tools…

    4 条评论
  • Automation using power of Devops -Jenkins-Docker-Github

    Automation using power of Devops -Jenkins-Docker-Github

    Problem Statement:- Create docker file which will install Jenkins. As soon we run this docker image or docker file it…

    6 条评论
  • Automation project using pipelines,jenkins,github,gitbash,docker

    Automation project using pipelines,jenkins,github,gitbash,docker

    This is my first mini project of DevOps under the guidance of Mr. Vimal Dada sir and Linux World Information Pvt Ltd.

    5 条评论
  • Cloud server

    Cloud server

    Docker Docker is a tool designed to make it easier to create, deploy, and run applications by using containers…

    7 条评论

社区洞察

其他会员也浏览了