Jenkins Operator in kubernetes cluster(Part 1)

Reading Time: 5 minutes

Hi folks ,We’re going to learn about how to use Jenkins Operator in kubernetes cluster to manage jenkins instances and to understand it . So i’m assuming that you’re familiar with the below listing….

  • jenkins installation
  • how to run jenkins in your kubernetes cluster

Now, I’m using the Rancher k3d kubernetes in Docker Container as I wanted to trysomething new and it’s lightning fast  in terms of less docker image size because k3d uses docker images .

If you want to use it then follow the instructions:

As i’m using v3.3.0 you can use other tags also and now to make it executable:

$ chmod +x k3d-linux-amd64

Moving from Downloads to usr/local/bin as k3d

$ sudo mv k3d-linux-amd64 /usr/local/bin/k3d

To create kubernetes cluster :

$ k3d cluster create cluster-name

NOTE: if you don’t specify cluster-name it will automatically set it to default name.

similarly If you want to add more worker nodes to your cluster:

$ k3d cluster create –agents 1

You can specify the number of nodes .

$ k3d get nodes

Jenkins Operator  kubernetes cluster

As you can see  I have two nodes , one master and another worker node .

similarly You can delete the cluster easily and perform other operations too , you maycheckout the documentation or below commands:

$ k3d help

$ k3d cluster help

Now let’s see the Jenkins Operator:

What’s the Jenkins Operator?

The Jenkins Operator is a Kubernetes Native Operator which manages operations forJenkins on Kubernetes. However It has been built with Immutability and declarativeConfiguration as Code in mind.


Considering that this Operator is created for managing instances for Jenkins, it is important to understand what


In other words With the Jenkins Operator project we want to enable the community to run Jenkins in cloud-native environments like Kubernetes. Also, support most of the public cloud providers (AWS, Azure, GCP) in terms of additional capabilities like backups, observability and cloud security.

So With declarative configuration and full lifecycle management based on the OperatorFramework this can become the de facto standard for running Jenkins on top of Kubernetes.

Installation of Jenkins Operator:

To run Jenkins Operator , you will need

  • Access to kubernetes cluster version 1.17+
  • Kubectl version 1.17+

For instance ,Listed below are the two ways to deploy Jenkins Operator.

Deploy Jenkins Operator using YAML’s

So first, install Jenkins Custom Resource Definition

kubectl apply -f

Then, install the Operator and other required resources:

kubectl apply -f

Watch Jenkins Operator instance being created:

$ Kubectl get pods 

Jenkins Operator  kubernetes cluster

Now Jenkins Operator should be up and running in the default namespace.

$ kubectl get svc

Jenkins Operator  kubernetes cluster

So here I’ve got the local-path because when you deploy a cluster using k3s and k3d you automatically get a local-path storage class .

After power off the system you need to start  existing k3d cluster(s) like below:

Jenkins Operator  kubernetes cluster

$ kubectl get all

Jenkins Operator  kubernetes cluster

Now as you can see that jenkins-operator is running and you also can see here it has got one container, service , deployment and replica set.

Deploy Jenkins Operator using Helm Chart:

Alternatively, you can also use Helm to install the Operator (and optionally, by default, Jenkins). It requires the Helm 3+ for deployment.

Before begin with you need to have helm installed :

$ helm short –version

Jenkins Operator  kubernetes cluster

Therefore to install, you need only to type these commands:

$ helm repo add jenkins

After that update the helm repo : $ helm repo update and $ helm repo list

$ helm install <name> jenkins/jenkins-operator

Jenkins Operator  kubernetes cluster

It has also given us some information about how we can access the first jenkins instance .

$ helm list

So jenkins operator status is deployed.

$ kubectl get all

Now jenkins-operator is running and it has got two containers and some couple of services one for dashboard ( port 8080) and 50000 .

which is the port jenkins will be listening on for connections from the slave agents.

when you deploy slave agents they can connect to jenkins instance using this port 50000 .

for every jenkins instance you deploy you will have two services created one for the dashboard and another for

slave listeners.

$ kubectl get jenkins

So how do we access it?

To check the status of jenkins-operator:

$ helm status jenkins-operator

It has given us a couple of commands to actually find out what username and password to use to login to jenkins.

So let’s find that out first:

$ kubectl get secrets

So jenkins-operator-credentials-jenkins contains the username and password that we need to login to the jenkins instance.


$ kubectl –namespace default get secret jenkins-operator-credentials-jenkins -o ‘jsonpath={.data.user}’ | base64 -d


$ kubectl –namespace default get secret jenkins-operator-credentials-jenkins -o ‘jsonpath={.data.password}’ | base64 -d

$ kubectl get svc

So highlighted one we need to access but it’s actually cluster-ip not exposed outside the cluster.

So either you need to exposed it with load-balancer or node port or simply port-forwarding.

After that, we can do port-forwarding , helm gives us the command to do that:

$ helm status jenkins-operator

  • Connect to Jenkins (actual Kubernetes cluster):
  • $ kubectl –namespace default port-forward jenkins-jenkins 8080:8080

So Now we’re logged in to our jenkins dashboard. It’s our first jenkins instance.

similarly for another jenkins instance refer to part 2.

Written by 

A curious DevOps Intern , love to learn and working on technical skills/tools, know the basics of Linux, Docker, Ansible , Kubernetes and more..