How to Setup Jenkins on Kubernetes Cluster with Helm
Tags: devops, kubernetes, programming, codenewbie
Published: 2023-06-02 15:14:37

[Jenkins](https://www.jenkins.io/) is an open-source multi-platform software for continuous integration/continuous delivery and deployment (CI/CD) in DevOps. It is one of the most common CI/CD tools. Jenkins uses CI/CD pipelines to automate the software development and deployment workflows. Jenkins uses plugins to integrate with DevOps tools such as Docker and Kubernetes. Jenkins plugins can also be used to integrate with cloud providers such as Google Cloud, AWS, and Microsoft Azure. If you want to integrate any DevOps tool with Jenkins, you have to install its plugin in the Jenkins controller platform. You can check this [article](https://sweetcode.io/how-to-build-and-push-docker-images-to-docker-hub-using-jenkins-pipeline/) on Sweet Code about Jenkins.

In this tutorial, you will learn how to set up Jenkins CI/CD on Kubernetes Cluster using Helm. Helm is one of the easiest ways of installing an application on the Kubernetes Cluster. 

### Prerequisites
For you to follow this tutorial on how to Setup Jenkins CI/CD on Kubernetes Cluster using Helm, you must:

- Have Docker set up and understand how to use Docker: You can check out this [article](https://sweetcode.io/understanding-docker-image-layers/) on Sweet Code to set up and understand Docker.
- Understand Kubernetes. You can check out this [article](https://sweetcode.io/how-to-deploy-react-js-and-node-js-dockerized-containers-to-kubernetes-cluster/) on Sweet Code to understand Kubernetes.

### How to Setup Jenkins CI/CD on Kubernetes Cluster using Helm
[Helm](https://helm.sh/) is an open-source platform that was created by DeisLabs. Helm is used as the package manager for Kubernetes. Many developers use Helm to install any Kubernetes application to the Kubernetes Cluster. Helm automates the process of deploying a Kubernetes application to the Kubernetes Cluster. Helms bundles a Kubernetes application into a single package known as a Helm chart. Developers will then take this Helm chart and install them on the Kubernetes Cluster. You can check this [article](https://sweetcode.io/building-helm-charts-for-kubernetes-management/) on Sweet Code about deploying Helm Chart to Kubernetes.

A Helm chart contains all the Kubernetes YAML files for deploying a Kubernetes application. Once you install the Helm chart on the Kubernetes Cluster, it will create the Kubernetes components such as Kubernetes Deployment and Service on the Kubernetes cluster. You can create your Helm chart using Helm or you can reuse other people's Helm charts. You can check this [article](https://sweetcode.io/helm-package-manager-kubernetes/) on Sweet Code about Helm and Helm Charts.

Helm has an official Helm Chart repository called [ArtifactHub](https://artifacthub.io/) where developers can push and publish their Helm Charts. In this repository, you can easily find Helm charts for any Kubernetes application and reuse them. For complex applications like Jenkins, it is best to use the official Jenkins Helm Chart. Many Developers have contributed to the Jenkins Helm chart and it has all the Kubernetes YAML files. It will save us time in creating our custom Jenkins Helm chart. In this tutorial will search and download the official Jenkins Helm Chart from [ArtifactHub](https://artifacthub.io/). We will then install the official Jenkins Helm Chart on the Kubernetes Cluster using Helm. Let's install Helm.

### Installing Helm
Before you install Helm, you must configure/create a Kubernetes Cluster. We will install Helm on the configured Kubernetes Cluster. There are various Kubernetes Kubernetes Clusters that you can configure. Cloud providers like [Google Cloud](https://cloud.google.com/), [AWS](https://aws.amazon.com/), and [Microsoft Azure](https://azure.microsoft.com/en-us) have a dedicated Kubernetes Cluster that you can configure and use. In this tutorial, we will not use any of the cloud providers, instead, we will use a local Kubernetes called Minikube that comes with Docker. As long as you have Docker running you can easily configure Minikube. To configure and start Minikube, follow these steps:

Step One: Start Docker
Once you have started Docker, it is now easy to start Minikube.

Step Two: Configure and start Minikube
To configure and start Minikube Minikube, run this command in your shell:

 ```minikube
minikube start
```
Output:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wgqketun9jt0h9c464s9.png)

Now that we have configured and started our Kubernetes Cluster (Minikube), let's install Helm. There are different ways of installing Minikube on your specific operating system. I will show you how to install Helm on Linux, macOS, and Windows.

#### Linux
For Linux, you can run this command in your shell:

```sudo
sudo apt-get install helm
```

#### Windows
For Windows, you can run this command in your shell:

```choco
choco install kubernetes-helm
```

### macOs
For macOS, you can run this command in your shell:

```brew
brew install helm
```
I have installed Helm on my Windows operating system as shown below:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4trn1ixu5i7avm66my6.png)

To check if Helm is running in your Kubernetes cluster, run this  in your shell in your shell:

```helm
helm
```
The command should output the following in your terminal:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4gw5qytax04obgox8py.png)

After you have installed Helm on your specific operating system, the next step is to search for the official Jenkins Helm Chart on the [ArtifactHub](https://artifacthub.io/).

### Searching for the Official Jenkins Helm Chart
You can click on this [link](https://artifacthub.io/) to open ArtifactHub. You can then search for Jenkins as shown below:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dujao6nte9cq1374it66.png)

To use the official Jenkins Helm Chart, run this command in your shell:

```jenkins
helm repo add jenkins https://charts.jenkins.io
```
It will download and add the official Jenkins Helm Chart repository. To update this repository, run this command in your shell:

```jenkins
helm repo update
```
### Installing the Official Jenkins Helm Chart on the Kubernetes Cluster using Helm
To install the official Jenkins Helm Chart on the Kubernetes Cluster using Helm, run this command in your shell:

```jenkins
helm install myjenkins jenkins/jenkins
```
This command will deploy the Jenkins CI/CD on the Kubernetes cluster. Helm will use the Kubernetes YAML files in the Helm and create the Kubernetes components (Deployment and Service). We have reused the official Jenkins Helm Chart to set up the Jenkins CI/CD on the Kubernetes Cluster. 

Output:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4aczmff0b6z6zlfar03s.png)

To start using the Jenkins CI/CD running on the Kubernetes Cluster, follow these steps:

#### Step One: Get your 'admin' password for Unlocking Jenkins
To get the admin password, run this command in your shell:

```kubectl
kubectl exec --namespace default -it svc/myjenkins -c jenkins -- /bin/cat /run/secrets/chart-admin-password && echo
```
Admin Password Output:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4pn8p6g1b9z6rdk2ljkq.png)

#### Step Two: Get the Jenkins URL
To get the Jenkins URL, run the following shell command:

```kubectl
kubectl --namespace default port-forward svc/myjenkins 8080:8080
```
Output:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3b2a1anx67a2ai8w5o1l.png)

This command will expose the Jenkins container instance on port 8080. You can go to http://127.0.0.1:8080 to access the Jenkins CI/CD 

#### Step Three: Login into Jenkins with admin password and username
To login into Jenkins with an admin password and username, open http://127.0.0.1:8080 in your browser to access your running Jenkins container instance:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7uqia1nwk5h758v0usl.png)

You can then input your admin password and username to unlock the running Jenkins container instance.

#### Step Three: Finishing setting up Jenkins CI/CD 
To finish setting up Jenkins CI/CD  follow these steps:

Step One: Customize Jenkins
You will install the suggested plugins to customize Jenkins:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkuyqxazfd3s2g400d6n.png)

After a few minutes (depending on your internet speed), it will install the suggested plugins. Jenkins will use the plugins to integrate with other software:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/usmejxippmjea1j6d13n.png)

Step Two: Creating First Jenkins Admin User
You need to create a first Jenkins Admin user who will have control over the Jenkins platform. The Admin user will perform all actions/tasks in the Jenkins platform like starting CI/CD pipelines and managing Jenkins.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1kf3f1wlaosscbj9mol5.png)

You can input all the admin user details and then click the `Save and Continue` button. 

Step Three: Adding Jenkins URL
You can add the Jenkins URL as shown below:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okdnb0pwtljd1q9h6jnv.png)
You can click `Save and Finish` and Jenkins will be ready.

### Start using Jenkins
To start using Jenkins click on the `Start using Jenkins` button:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/03tqln26lh3mvpttvpru.png)

You can now start using Jenkins to create all your Jenkins CI/CD pipeline for automating the software development and deployment workflows. You will have access to the Jenkins Dashboard as shown below:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdl7zcn7udu8qxsuw4ik.png)

You have successfully set up Jenkins CI/CD on Kubernetes using Helm. You can access the Jenkins Dashboard.

### Conclusion
In this tutorial, you have learned how to set up Jenkins CI/CD on Kubernetes Cluster using Helm. We used Helm because it's one of the easiest ways of installing an application on the Kubernetes Cluster. This tutorial shows you how to install Helm on Linux, macOS, and Windows. It also shows you how to search for the Official Jenkins Helm Chart. We also installed the official Jenkins Helm Chart on the Kubernetes Cluster using Helm.

Additionally, this tutorial shows you how to get your 'admin' password for unlocking Jenkins and how to login into Jenkins. In the end, we finished setting up Jenkins CI/CD on Kubernetes using Helm and accessed the Jenkins Dashboard. Hope this tutorial helps you in getting started with Jenkins.

If you like this tutorial, let's connect on [Twitter](https://twitter.com/wasike_bravin) and [LinkedIn](https://www.linkedin.com/in/bravin-wasike-976755198/) for more insightful DevOps articles, tips and discussions.