Deploy Jenkins in Kubernetes using Helm chart

Kalla kruparaju
6 min readSep 26, 2021

--

Hello Technical Folks ‼️

In this article i would to explain about what is Helm Chart and how to deploy Jenkins in the Kubernetes using the Helm chart

Prerequisite setup of kubernetes need to do this partical here I am using Minikube single node kubernetes cluster which can run it in our local system in the virtual machine setup.

Lets start the minkube single node cluster

What is Helm?

Helm is a tool which allows to manage Kubernetes based applications by providing a standard approach for defining how we install, upgrade and uninstall applications. It is a package manager for Kubernetes and the best way to find, share, and use software built for Kubernetes

Allows developers to easily package, configure, and deploy applications and services onto Kubernetes clusters through Helm Charts. Charts are files that are written in YAML and packaged in a particular directory structure which can be versioned within any source control systems. These charts describe a set of Kubernetes resources which makes up the entire application

Helm is an official Kubernetes project and is part of the Cloud Native Computing Foundation(CNCF)
Helm can:
✓ Install software
✓ Automatically install software dependencies
✓ Upgrade software
✓ Configure software deployments
✓ Fetch software packages from repositories called Charts repository

Offers a simple way to package all application resources into one single chart and advertises what you can configure. Hiding the complexity of running multiple YAML files to deploy the application. Instead we run a single command that install all YAML files at once. Easy management of application releases. Same chart can be used for different environment like dev, staging and prod.

Helm Architecture and Working

Helm had the client-server architecture till version 2, We have to need to install a server-side program Tiller in the Kubernetes cluster.

In version 3 helm provides more facilities i.e. install helm on the client-side only. It provides more security than version 2. We can install helm in Mac, Windows, and Linux.

Installing Helm

Download the desired version from this Link. Unpack the downloaded tar file and move the helm binary in the unpacked directory move it to into the environment variable because in the command line everywhere we can do access helm.

What is Jenkins?

Jenkins is a free and open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. It is a server-based system that runs in servlet containers such as Apache Tomcat.

Now we have successfully setup the Helm configuration in the system it is also working great. Let’s create the Chart for the Jenkins

Create a Helm Chart

let’s create a new Helm Chart from the scratch. Helm created a bunch of files for you that are usually important for a production-ready service in Kubernetes. To concentrate on the most important parts, we can remove a lot of the created files. Let’s go through the only required files for this example.

Create a Helm Chart for Jenkins

mkdir jenkins
cd jenkins

But here we need a project file that is called Chart.yaml and contains all the metadata information about the chart, such as chart name and version, maintainer information, a relevant website, and search keywords.
So, create this file. Also, C should be capital in the Chart.yaml.

vim Chart.yaml

Write the below code inside Chart.yaml

Make a templates folder inside jenkins and go inside it. This directory contains template files that are combined with configuration values and rendered into Kubernetes manifests.

mkdir templates
cd templates

Create a YAML file for launching the deployment for Jenkins inside the templates folder. Write the below code inside deployment.yaml

Create YAML file for exposing the services of Jenkins inside the templates folder. . Write the below code inside service.yaml

A Helm chart is composed of the following files:
├── Chart.yaml
├── templates
├── deployment.yaml
└── service.yaml

Now we will install the chart as we create earlier using helm

helm install <chart_name> folder_name/

Now, our Jenkins deployment and service has been install also with the following commands

kubectl get deploy
kubectl get pods
kubectl get svc

After running the command pick the port number that has been exposed jenkins service. And If you run a single node cluster minikube, run below command to check ip.

minikube ip

Note: This command will give ip of your minikube enter it in the below URL

Now type http://<minikube ip>:<port_no> in browser. A page will appear asking for an administrator password

Let’s use kubectl to pull the password from those logs.

kubectl logs <pod_name>

The selected text is the initial password to login to Jenkins copy the password and paste into Jenkins UI.

Click continue and install the packages

Now the jenkins setup is ready you can run any jobs with the help of jenkins !!

Publish Helm Chart on Artifacthub.io

Artifact hub is a web-based application that helps to storing and installing helm packages. It is a public repository everyone can contribute to it by creating and publishing charts for any technologies.

Hosting Chart using Github Pages

🔸 We must require a URL where we had hosted our helm chart for publishing the Helm chart on artifacthub.io/. One of the ways to host the charts is using GitHub pages. So, we will first host our charts using GitHub pages. Go to the settings of your Github repository and go down where you can see the GitHub Pages section. Select main as a branch and click on save.

Now create a chart package and index file to the chart and merge the indexfile with the url

Add the files in the github repository

Publishing helm chart on artifact hub

Go to this URL artifacthub.io/ Sign in with your account if you have otherwise you have to need to create an account. After signed in successfully, In the right top corner click on the face you have seen.

Now click on profile icon > control Panel> Add repository.

Note: Make sure your repository’s url should be like where the chart package is located https://username.github.io/repository_name/ when you're adding repository in ArtifactHub. Otherwise, it can create some issues related to url.

After giving the required information to your Helm repository, click on Add. if you had provided the right information then it will create a Helm repository.

So, we had successfully published our Helm chart to the ArtifactHub.

Thanks for reading !!!

--

--

No responses yet