Deploy Jenkins Server In K8s Cluster Using Helm On AWS Cloud
What is Helm ?
Let’s take example from our O.S. if you are using RedHat 8 there we have package manager to update, install and manage dependencies . Similarly in K8s we have Helm as Package Manager and Package is called Chart.
We can relate it in this way:
RedHat Package Manager -> rpm, dnf, yum
K8s Package Manager -> Helm
Helm helps you to manage Kubernetes applications. Helm Charts helps you to install, manage and upgrade even the most complex applications. Helm is a third part tool that manages K8s package.
Package in Kubernetes is known as Charts. Either we can download Charts from some repository or we can create our own custom chart. In this article we choose to create own custom chart.
Installing Helm
You have to install Helm in client side. Most common and preferred way is to install it from binary.
Helm has two version v2 and v3 which one should I go for ?
So let’s understand what are the differences in these two versions. In version2 of Helm we have to install Tiler program in server. What is Tiller Program? Consider this example when we create a Chart from client side on deploying multi-tier architecture where WordPress will be our frontend and MySQL will be the backend, while we deploy this chart to Kubernetes Cluster so on server side there will be a program that communicates with the Kubernetes API to manage our Helm Packages. This software is called Tiller.
But in v3 of Helm we don’t have to install tiller program externally it’s inbuilt in version3 of Helm.
So, it’s recommended to go for Helm version3.
Here you will find the link for downloading the binary of Helm Version 3
Use this command to extract this binary
Copy the directory linux-amd64/helm to /usr/bin/
You can check the version of Helm by the below command
helm version
For this task I used AWS Cloud for setting up K8s Master and K8s Slave. If you are interested in setting up this cluster you can watch this video. In this video I have showed how we can create a multi-tier architecture and also provided the link of my GitHub repo from where you can have the ansible roles.
After setting up K8s Cluster let’s start creating our own custom charts.
Create a workspace where we will create Charts.
Configuration file for the chart is Chart.yaml . We have to create Chart.yaml and it is compulsory to have capital ‘C’ in Chart.yaml.
Content we have to specified inside Chart.yaml
Create template directory inside your workspace.
You can create deployment.yaml by the command provided below. In this deployment code we will use the Jenkins image.
Our yaml code for deployment.yaml will look like this.
Now install the helm chart.
Let’s check whether the pods are running or not?
Now we can check there is none services running apart from kubernetes of type Cluster-Ip . Now we will expose the Jenkins server so that we can configure it.
Now let’s create a service.yaml file by using dry-run approach.
Inside service.yaml file.
Let’s see the new services has launched or not?
Now as we have modified our charts, then we have to upgrade our chart.
Now we can check that our Jenkins server is publicly accessible or not. By hitting to the http://public_ip_address_slavenode:exposed_port
For getting the password of running Jenkins server, we will do login inside the pod and view the file that contains the Jenkins server password.
Location of the password file: /var/jenkins_home/secrets/initialAdminPassword
Now from the above file we can copy the password and enter it in the Jenkins Server.
Now you can configure it according to the requirements.
That’s all for now. Thanks for reading this article I hope it would help you in creating your own custom Helm Charts. You can integrate any other technology with the Kubernetes Package Manager and can automate the things.