DevOps-Project-3

DevOps-Project-3


This article contain complete integration of git , github , jenkins , Kubernetes for deploying the web page by automation. I have launch complete environment for jenkins process using Dockerfile.

Task

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 job1, job2, job3 and job4 using build pipeline plugin in Jenkins 

4. Job1 : Pull the Github repo automatically when some developers push repo to Github.

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

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

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.

Prerequisite for this project is

  • I have windows operating system in which i have already install git bash ,
  • kubernetes and kubectl have configured.
  • I have Redhat 8 operating system which is running on the top of windows by virtualization. in this, my Docker is running.
  • for Source Code Management i have github account and i have also account on hub.docker.com where i can push my images.
  • and i have stop the firewall using systemctl stop firewalld and selinux using setenforce 0 so that there will no issue in connectivity between two VM.

__________________________________________________________________________

Start Building

There is two section 1. Operation section 2. Developer section

1.Operation Section

The DevOps role pulled operations into the team, including ownership of the test servers, concerns about rollout and managing the rollout itself. A team that is pursuing DevOps likely owns responsibility for production servers, including monitoring and managing those servers.

First we have to create Jenkins Docker image in which we have to configure kubectl too.

In the below screenshot I have created a Dockerfile in which i have install all the the software that will use in my project.

No alt text provided for this image
  • I am copying some file like client.key , ca.crt , client.crt these are the key and certificate for configure the kubectl in another vm. because my kubernetes and kubectl is install in my windows operating system. now i am configuring kubectl in another vm that's why i need these files.
  • i am copying another file which is myinfo
No alt text provided for this image
  • this is file is for configure the kubectl command. it include all the information which is required the kubeclt to run in another vm like: ip and port number of minikube and location of keys and certificates.

Build this image using command

"docker build -t devops . "

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

Launch a container using this image using command

"docker run -dit -p 8086:8080 --name jenkins devops:v2"

No alt text provided for this image

we can get the initial password of Jenkins using command

docker exec <container name> cat /var/lib/jenkins/secrets/initialAdminPassword" as shown above on the image.

now browse and access the Jenkins using Ip of base os and port no

192.168.43.199:8086

No alt text provided for this image

now complete setup is done of jenkins. so we can start creating job in jenkins

before start creating the job i have installed github , build pipeline, email Notification plugin in jenkins.

JOB-1

  • In job i am putting my github repository url in git section sp that i can download all the code uploaded by developer.
  • I am scheduling my job using pollscm it will go to github and check the impormation at every minute.
  • I am copying all the data in the folder /Job1
No alt text provided for this image
No alt text provided for this image

JOB-2

  • This job contain some kubectl commands that will deploy the web page on the top of kubernetes.
  • and copying file in the directory (/var/www/html) of pod that contain code of web page.
  • this job will depends on the job1
No alt text provided for this image

JOB-3

  • According to given instruction for job3 . i am using status code and exit code in the job3. if any error will we in the code it will automatically stop with exit 1 and it will fail the job3 .and if everything is good then it will stop with exit 0 and it will not fail the job3. and job2 will trigger the job3.
  • this job depends on job2
No alt text provided for this image

JOB-4

Before creating job4 we need to configure email. for this go to configuration system and give some necessary information as given below.

No alt text provided for this image
  • Just i am putting my email id in the email Notification section and i have give less security power to my email which is must to send email.
  • and in the attach build log we can put attach the log of console output
  • this job depends on job3 .
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

All the job is completed, so I have created a build pipeline. my all four jobs are dependent to each other. so as soon as developer will push the code on github then job1 will automatically will start and other job also will start.

2.Developer section

DevOps Engineer works with developers and the IT staff to oversee the code releases. They are either developers who get interested in deployment and network operations or sysadmins who have a passion for scripting and coding and move into the development side where they can improve the planning of test and deployment.

So here developer written code in a file webconfig.yml to deploy web page on the top of kubernetes.

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

and some others files that contain some html code

No alt text provided for this image

and then push it github repository

No alt text provided for this image

as soon as developer push the code to github job1 will trigger because pollscm checking information at every minutes.

No alt text provided for this image

once the job1 successfully done job2 will be trigger.

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

here we can access our webpage using "<minikubeIP:32000"

No alt text provided for this image

here i am sharing console output of all the jobs

JOB-1

No alt text provided for this image

JOB-2

No alt text provided for this image

JOB-3

No alt text provided for this image

JOB-4

No alt text provided for this image

and if job3 will be failed then we will get this type of message

No alt text provided for this image

I have done with all the setup

Thank You for reading this article...................

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

Km Sulekha的更多文章

  • Docker GUI Task26

    Docker GUI Task26

    This article describe how we can launch GUI software on Docker. Task Description *GUI container* on the *Docker* Launch…

  • HotStar Case Study Task2

    HotStar Case Study Task2

    This article will describe the journey of Hotstar’s infrastructure from EC2 to Kubernetes. The journey about why, what,…

    1 条评论
  • Case Study of AWS SQS

    Case Study of AWS SQS

    In this article I am going to share what is Amazon SQS and industries use case of Amazon SQS. Amazon SQS Amazon Simple…

  • ARTH Task18

    ARTH Task18

    In this article we are going to explain how to we can configure WordPress on ec2 instances and connect this with Amazon…

  • Arth2020 Task17

    Arth2020 Task17

    In this article we are going to create chat program using python socket programming and Threading. Task Description…

    2 条评论
  • Create a setup so that you can ping google but not able to ping Facebook from same system Task13

    Create a setup so that you can ping google but not able to ping Facebook from same system Task13

    This article is to explain how we can create an interesting networking setup in which only we can reach to google but…

  • How big MNC's like Google , Amazon etc stores, manages and manipulate Thousands of Terabytpes of data with High Speed and High Efficiency Task-1

    How big MNC's like Google , Amazon etc stores, manages and manipulate Thousands of Terabytpes of data with High Speed and High Efficiency Task-1

    In a world where competition is intense, users will simply dump you, if your app slows down or freezes. So your…

  • Industries use case of AKS ?

    Industries use case of AKS ?

    Kubernetes is by far the most popular container orchestration tool, yet the complexities of managing the tool have led…

  • Ansible-Tower

    Ansible-Tower

    In this 3 hours of session we learn practical demo how industries are using Ansible-Tower and how it gives lots of…

  • Arth2020 task12

    Arth2020 task12

    This article is to explain how to configure a highly automated setup for Reverse proxy i.e Haproxy and update it's…

    5 条评论

社区洞察

其他会员也浏览了