Integration of Github & Jenkins over Kubernetes.
What is jenkins?
Jenkins is an open-source automation tool written in Java with plugins built for Continuous Integration purposes. Jenkins is used to build and test your software projects continuously making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. It also allows you to continuously deliver your software by integrating with a large number of testing and deployment technologies.
With Jenkins, organizations can accelerate the software development process through automation. Jenkins integrates development life-cycle processes of all kinds, including build, document, test, package, stage, deploy, static analysis, and much more.
What is Github?
GitHub, Inc. is a United States-based global company that provides hosting for software development and version control using Git. It has been a subsidiary of Microsoft since 2018. It offers the distributed version control and source code management (SCM) functionality of Git, plus its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.
GitHub offers its basic services free of charge. Its more advanced professional and enterprise services are commercial. Free GitHub accounts are commonly used to host open-source projects. As of January 2019, GitHub offers unlimited private repositories to all plans, including free accounts, but allowed only up to three collaborators per repository for free. Starting from April 15, 2020, the free plan allows unlimited collaborators, but restricts private repositories to 2,000 actions minutes per month. As of January 2020, GitHub reports having over 40 million users and more than 100 million repositories (including at least 28 million public repositories), making it the largest host of source code in the world.
What is kubernetes?
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”. It works with a range of container tools, including Docker. Many cloud services offer a Kubernetes-based platform or infrastructure as a service (PaaS or IaaS) on which Kubernetes can be deployed as a platform-providing service. Many vendors also provide their own branded Kubernetes distributions.
Perform second task on top of Kubernetes where we use Kubernetes resources like Pods, ReplicaSet, Deployment, PVC and Service.
- 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.
Task 2 link- https://email@example.com/build-check-test-monitor-you-code-using-integration-of-github-docker-jenkins-task-2-d0083a8d7e6
Here the task begins…
- First we have to make the docker image in which all the services are running.
This is the Dockerfile..
Now build this by using this cmd..
docker build -t jenkins-k8s:v1 /devtask3/
After it build successfully then push it to Dockerhub by using this cmd..
docker push username/filename:tag
So now first start our minikube..
Here the creation of yml file start.
Run this yml file with kubectl cmd.
kubectl apply -f jenkins.yml
Check weather your pod is ready or not.
kubectl get all
Here my pods are ready..
Use this cmd for get the password of jenkins.
kubectl logs podname
Use the minikube IP address and launch the jenkins.
Now we have to make the jobs of our task..
Job1: we will be copying our code from Github to our workstation this code will be saved in /host/files folder.
Job2: Here we will be checking the code type for eg its HTML, PHP or any other I only wrote condition for HTML we can write more by using if-else
Job3: Here we will check weather our website is working properly or not.
Now the build pipeline view will see like this.
That’s all about my task.