WebServer on Kubernetes Cluster via Jenkins (Groovy Script approach)

Jenkins + Kubernetes

This task has been completely implemented on RHEL 8. It is assumed that Jenkins, Minikube and Kubectl are already set up on your system.

**The kubectl is set up on host OS that will control our minikube. Minikube is available in VM. Host OS and Minikube are on a common network.

Jenkins Job list:

  1. Seed Job: This job is configured with a webhook. It will download the groovy script pushed by developers and create jobs and views as required by the operations team.
  2. The created jobs in our case have been specified to us and will be explained in the solution itself.


Plugins required to be installed:

  1. Job DSL
  2. Script Security Plugin
  3. GitHub plugin
  4. Workspace Cleanup Plugin (to clean workspace before every build)
  5. CloudBees Docker Build and Publish plugin
  6. Email Extension Plugin
  7. Build Pipeline Plugin

GitHub plugin and use of webhooks can be found here :


This a seed kob attached to a webhook. It will run every time a developer pushes an update. Here we are given what these jobs will perform which are as follows:

Job1: Download and interpret the code from Github, build the image using given Dockerfile and push it to Dockerhub.

Job2: Deploy and expose your webserver on Kubernetes so testing can be performed accordingly.

Job3: Send status to the team as per the result of the build and deployment status.

Seed Job Configuration

This job will not run directly so we need to tweak somethings in the security settings so we don’t face any problems.

Manage Jenkins >> Configure Global Security

This will disable security checks on DSL scripts else on every build you will have to approve the script.

After you build it, you get three new jobs and a new view in Build Pipeline. (Build Pipeline has a known bug, it won’t show the build pipeline until you change its name on every build. It would be created just not visible.)

Seed Job — Build Successful
Jobs and Build Pipeline View

** The jobs in the view will be visible after you start first build.

The code is available here for your reference.

This is the documentation I referred to write my codes. Refer here for help and if you have any doubts, contact me.

Now after we run the main jobs, here are the outputs on the first deployment and update rollout.

Deployment stages
E-Mail Notifications

Thanks for giving time. All doubts and suggestion are welcome.

Worked in collaboration with Daksh Jain.

Connect me on my LinkedIn as well.




Just a tech enthusiast… Research, implement and share is what I like to do

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Flink Forward Berlin 2017

Intro to the Rate Limiting Policy

How to connect your Amazon EC2 instance with a domain name

Google Analytics in Technical Writing — What For?

Quantum Perceptron

Accessible Form Validation Messages with ARIA and Vue.js

Golang short variable declaration

How to Deploy a Python Microservice on Fargate (Part 2)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ashish Kumar

Ashish Kumar

Just a tech enthusiast… Research, implement and share is what I like to do

More from Medium

Minikube installation | Kubernetes Tutorial

Kubernetes — Deploying microservices

Best Practices For Building a CI/CD Pipeline with Jenkins