Jenkins and Groovy on Kubernetes
What is Groovy?
It is language in which we can write the code and steps to run JOBs of Jenkins. This language is very easy and can be written by anyone. This is also a great advantage, that developers who don't about the administration much can easily make the cod and run the jobs in Jenkins.
Problem Statement:
Perform third task with the help of Jenkins coding file ( called as jenkinsfile approach ) and perform the with following phases:
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. Job2 ( Seed Job ) : Pull the Github repo automatically when some developers push repo to Github.
5. Further on jobs should be pipeline using written code using Groovy language by the developer
6. Job1 :
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 using PVC ( If server collects some data like logs, other user information )
7. Job3 : Test your app if it is working or not.
8. 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 develop
Solution:
We have to create an image in which jenkins , kubernetes and other things will be configured.
Creating a docker image:
Building Docker Image:
Now creating persistent volume claim:
Now creating service :
Creating deployment:
Now the groovy code for making the JOB is written in my Github repo.
Now we have to make a seed job for downloading this code.
I have named it "Groovy_dsl"
I have added my Github repository here.
Now, as soon as this job will run the new job will run.
Thanks for reading :)
Data Scientist & Machine Learning Engineer | Building Scalable Models for Real-World Impact
4 年Well done??Aastha Saxena ??