My recent posts have been discussing manually creating Kubernetes resources but, as I pointed out in an earlier post, there is an easier way to deploy Kubernetes resources and that is Helm.

What is Helm?

Helm is a package manager for Kubernetes. A bit like apt in Debian Linux, or yum in Red Hat Linux. Except Helm refers to charts instead of packages, keeping in line with Kubernetes nautical theme.

How is Helm installed?

By default Helm does not come with Kubernetes, but it is easy to install. Visit Helm’s GitHub pages (https://github.com/helm/helm/releases) and grab the latest release for your OS/architecture. For me, currently on Ubuntu on an AMD64 based architecture, that was (at time of writing) version 4.1.1.

# curl to download version 4.1.1
curl https://get.helm.sh/helm-v4.1.1-linux-amd64.tar.gz -o helm-v4.1.1-linux-amd64.tar.gz
# tar to extract the archive
tar -zxvf helm-v4.1.1-linux-amd64.tar.gz
# copying helm to /usr/bin/ so it can be called using the word helm
linux-amd64/helm /usr/local/bin/helm
# check helm version
helm version

Using Helm

Helm uses your kubeconfig file to know where your Kubernetes cluster is and what credentials to use. So by default it looks for the $KUBECONFIG environment variable, and if that is not set it then checks for $HOME/.kube/config.

The first step to using Helm is chart repositories. A chart repository tells Helm about the charts we want to use. Helm has options for chart repositories:

helm search hub
#searching for WordPress
helm search hub wordpress

This searches the whole of the artifact hub and at times can return a lot of results which can be overwhelming.

To limit the search to a chart repository we first add the repository:

#adding Bitnami repository
helm repo add bitnami https://charts.bitnami.com/bitnami

The repo add command asks you to name the repository, in the above I have called it “bitnami” and then asks for the URL of the charts. To check what repositories have been added use:

helm repo list

The helm search repo command can now be used to search just the repositories added, instead of the whole hub.

helm search repo
#searching for WordPress
helm search repo wordpress

This shows the latest version of the chart available. However, with –versions it is possible to see all chart versions that are available.

helm search repo wordpress --versions

Installing a package

Installing a package can be achieved using helm install:

helm install INSTANCENAME repository/packageName
# install a WordPress instance, from Bitnami with the name mywordpress
helm install mywordpress bitnami/wordpress

The command can be run without an instance name, but I recommend using the instance name option as it makes tracking and interacting with the installed package easier later on.

Viewing what Helm has installed

Any deployed packages will show via the regular kubectl commands (e.g. kubectl get pods) but Helm also provides a list command:

helm list

Uninstalling A Helm package

Just as helm install can add a package, helm uninstall can remove a package.

helm uninstall instancename
#e.g. Removing mywordpress instance
helm uninstall mywordpress