Integration of kubernates with Jenkins and git on RHEL-8

7 min readJun 23, 2023


Kubernates :

Kubernetes is an open source container orchestration engine for automating deployment, scaling, and management of containerized applications. The open source project is hosted by the Cloud Native Computing Foundation (CNCF).

What is Jenkins?

Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.

Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with a Java Runtime Environment (JRE) installed.

Current Setup

  • Jenkins running on RHEL-8 inside VM (oracle virtual Box)
  • kubenates (minikube running on windows)


A Kubernetes cluster can be deployed on either physical or virtual machines. To get started with Kubernetes development, you can use Minikube.

Minikube is a lightweight Kubernetes implementation that creates a VM on your local machine and deploys a simple cluster containing only one node. Minikube is available for Linux, macOS, and Windows systems. The Minikube CLI provides basic bootstrapping operations for working with your cluster, including start, stop, status, and delete

1. Let’s First Setup Kubernates on RHEL-8

Networking Setup

As my Rhel is running on VM need outside connectivity as well as Local Connectivity , also for Local connectivity NAT can’t work so add one more network card to your RHEL i.e Host-only adapter which provide local connectivity

Steps to add Network in VM

  • Stop the VM (if running)
  • go to setting
  • add Host-only adapter

Note: Add on the same machine where Jenkins is Running

  • Do same thing on minikube VM

Till Now we are using Windows as our workstation , Now we using RHEL-8 as our workstation

NAT: To provide connectivity with internet because may be run our k8s in Laptop, cloud, VM or anywhere in the World

Host-only adapter which provide local connectivity i.e Local VM

After Setup of Network check the Connectivity between RHEL and kubernates(minikube VM)

Get the ip of minikube running on windows

# minikube ip , and ping it

As kubectl is not present on our RHEL ,but

What is kubectl used for?

kubectl : The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs

Now go and download kubectl on linux

After Downloading do these steps

# ls -l kubectl

# chmod +x kubectl (make it executable)

# mv kubectl /usr/bin/

Now To get resources and to connect let’s Go Step by step

# kubeclt get pods

you will see the error because you haven’t said where is your server

# kubectl get pods — server IP:port no (of minikube)

default port: 8443

This will again give the error i.e server rejected , because to make it secure we have to provide the Authentication i.e keys to connect

As our minikube is running on windows , so go to the location where your minikube is installed get the keys and transfer it into Rhel-VM

  1. client.crt
  2. client.key
  3. ca.crt (present to directory back of give location)

In my case location is:


Transfer all these 3-file to your Rhel from windows…

Note: You can use WinScp Softwere to transfer the file from windows

you see in my case files are transferred in /root location

Now, let’s Get the Pods

# kubectl get pods — server https://********:8443 — client-key /root/client.key — client-certificate /root/client.crt — certificate-authority /root/ca.crt

O/p : No Resource found

# kubectl run myweb — image httpd — server — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — same command


# kubectl get pods — server — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — same command

As we are writting this long code again and again so copy it into one file

# vim myinfo.yml (provide here all the information i.e configuration)

Now , if you check

# kubectl get pods — kubecinfig myinfo.yml

here also we are writing — — kubeconfig again and again


# mkdir .kube (may be already exist)

# cp myinfo.yml .kube/config

Now, if you run

# kubectl get pods

# kubectl run myweb — image=httpd

Note: In windows minikube Already done these steps, we have seen in windows

# kubectl config view


2. Integationwith the Jenkins

As my jenkins is running on Rhel-8

# systemctl status jenkins

Start Jenkins

  • create one Job which pull the Code
  • Launch the pods using Deployment
  • Expose the pod

Now As I have pushed some Deployment code on git hub to launch the pod

find code here:

Create one job which pull the code from git hub

i have putted the trigger , as soon as code push to github it will automatically fetch the code

After build we get o/p

Let create another Job which is responsible to launch the Pod using Deployment also Create the chain, i.e Run Job-2 only if Job-1 successfully completed

And after running this job we see our deployment is launched

Expose the Deployment

Now To expose provided one more file i.e service.yml

So, Either create one more job in the jenkins or run manually, the Service.yml automatically find find the pods because if I have created Label in such a way, just go through the yml file you will find the selector

I have given simple command , we can also write if-else script to make it more powerful


we have created the end to end automation to launch the k8s Deployment

if you find any difficulty connect with me on


Thank you

Aditya kumar Soni