Monday, April 27, 2020

What is Helm for Kubernetes?

In this post, I would like to talk about what is Helm and why do we need it, installing and uninstalling a chart and difference between a repo and a hub.

For this post, I am also assuming you are familiar with Kubernetes on a high level.

Before we dive into the details, first, let’s understand what does the word Helm mean in English.

“Helm is a lever or wheel controlling the rudder of a ship for steering.” – Merriam Webster

In a ship, you might have seen a wheel like mechanism used by the captain to steer the ship as shown below.

The logo for Helm (in Kubernetes context) as seen on website is shown below. We can now somewhat connect the dots with respect to logos.

If you want to setup wordpress inside a Kubernetes Cluster, then you will have to find relevant docker images for the wordpress front end and mysql database docker image and then setup networking, configuration, secrets, load balancing, etc., by installing multiple .yaml files.

After you have setup everything and everything is working, you will feel like you don’t want to touch your setup. But life doesn’t end there and eventually, you will have to worry about things listed below.

1. Delete deployments

2. Setup another wordpress instance for another customer

3. Update your images with new wordpress or mysql images

4. Rollback installation manually

and more.

Wouldn’t it be nice, if we didn’t had to worry about any of those .yaml files?

Wouldn’t it be nice, if we could leverage wordpress expert’s knowledge of installing and configuring wordpress into a cluster?

What if we could just execute few commands to install, uninstall and upgrade a software?

That’s what Helm does for Kubernetes. Helm helps you steer your software into your cluster.

You can execute helm commands against your K8S cluster such as

helm search hub bitnami/wordpress

helm install my-wordpress bitnami/wordpress

helm uninstall my-wordpress 

These commands would look familiar to you if you are familiar with apt-get or chocolatey or brew.

Helm is just like apt-get, chocolatey or brew, a Package Manager.

From the Helm website - “Helm is the package manager for Kubernetes. It is the best place to find, share and install software for Kubernetes”

It is the package manager for your Kubernetes Cluster and not for your machine.

You can install helm on your machine by following your operating system specific instructions as shown on the helm site -

Helm utilizes the same Kubernetes APIs to install software into K8S cluster.

A package manager is responsible for installing, uninstalling, and upgrading software packages into destination from a remote/local package repository.

Likewise, Helm works against a repository hosted locally or remotely. A repo can be hosted by anyone. For example, Google has its own helm repository. Bitnami hosts its own repository.

A repository contains many software packages. Each package has multiple versions.

Within helm context, a package is called a Chart. From now on we will refer packages as Charts.

By default, helm doesn’t know about any repository. If you want to use a particular repository, then you have to first add that repository to helm.

helm repo add bitnami

After you have done that, you can install any software from bitnami repository.

helm install my-wordpress bitnami/wordpress

When you execute the above command, you are telling helm to install the wordpress chart from the bitnami repository.

You can uninstall a chart by

helm uninstall my-wordpress

A small recap – Helm is a package manager that works against one or more repositories hosted by anyone to install/uninstall/upgrade a chart into a Kubernetes Cluster.

Are you with me so far? If yes, then let’s continue.

Since, repositories can be hosted by anyone (some of them could be private or public), how to find and search charts within these repositories?

Do we have to add every single repository out there?

How do we discover these repositories?

Helm Hub is a central location to easily find charts that are hosted outside the helm project.

When you execute the command helm search –help, you are presented with two options search hub or search repo. In the below comands, we are searching for wordpress chart against the hub and then against the repository.

helm search hub wordpress

helm search repo wordpress

What happens when you install a chart (remember we called it package initially)?

A Chart is nothing but collection of files that describe a related set of Kubernetes resources. For example, a wordpress chart will have all the .yaml files required to install wordpress. In addition to that it will have metadata information about the chart itself.

When you install a chart, it creates a new release into your K8S cluster. A release is like an instance of a resource. For example, when you install wordpress chart using the install command mentioned earlier, it will create a new release by the name my-wordpress. That release is unique to this cluster.

You can install a chart multiple times to create multiple releases. For example, if you can install wordpress chart 3 times, then you will have 3 wordpress instances configured—all with their own unique urls, usernames and passwords. By executing the below command, we will have 3 releases installed in our cluster.

helm install my-wordpress1 bitnami/wordpress

helm install my-wordpress2 bitnami/wordpress

helm install my-wordpress3 bitnami/wordpress


Take two, let’s say you install mysql chart 3 times in your cluster, then you have 3 mysql database instances configured in your cluster.

You can execute helm list command to see what is installed in your cluster.

Finally, you can uninstall a release by executing the command helm uninstall my-wordpress

I hope this helped your understand helm a bit better.

No comments:

Post a Comment