Since starting at Zeppelin, I’ve been learning Kubernetes in detail. While there is great documentation about K8S and tons of video tutorials, I’m a practical person that wants to jump in and learn along the way.

There are multiple ways to deploy applications to Kubernetes: One is writing the necessary YAML files directly, which is easy to start with, as you can just copy-paste things out of the documentation and adapt it to your needs - but it’s hard to make those files portable for multiple clusters or easily installable without further instructions. To solve this, Helm was created by the community.

What’s Helm?

In a nutshell, Helm is both a generator for YAML files using an extended version of Go’s template engine, as well as a “package manager” to install and update the generated files in a Kubernetes cluster.

Helm allows you to install complex applications into a cluster with just a couple of commands, for example to setup an entire metrics stack with Prometheus and Grafana, which by hand could take hours:

1
2
3
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
kubectl create ns prom
helm install -n prom prometheus prometheus-community/kube-prometheus-stack

This makes Helm look very easy to use, but I found writing own Helm charts quite challenging at first: When using the standard tool to create an “empty” project, you’ll receive a quite large and complex template, which contains files with a wild mix of YAML and go template mingled together:

Helm’s template Ingress

It’s quite pretty to look at, but what is even going on here? Helm has the same problem as Kubernetes: The sheer complexity at first can be quite… overwhelming.

The starter template was designed to be a fully useable base for web applications, but does every application really need a Horizontal Pod Autoscaler and it’s own ServiceAccount, when apiserver access is unnecessary?

Creating the smallest possible Helm chart

Fortunately I haven’t been the first with this problem, and someone else has already created a minimal starter template. And actually, we can go even smaller.

Just from looking at the starter template, you could get the impression that a ton of boilerplate is needed. But actually, a valid helm chart can be as small as 2 lines of YAML:

1
2
name: my-app
version: 1.0.0

Yepp, that’s all. Create a empty directory, save the above lines as Chart.yaml and install it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
$ helm install my-app .

NAME: my-app
LAST DEPLOYED: Fri Jun 11 20:26:15 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

$ helm ls

NAME  	NAMESPACE	REVISION	UPDATED                              	STATUS  	CHART       	APP VERSION
my-app	default  	1       	2021-06-11 20:26:15.909589 +0200 CEST	deployed	my-app-1.0.0

🥳

While an empty chart itself is kinda pointless, it’s a great starting point to slowly migrate your Kubernetes resource definitions to Helm, step by step (or resource by resource).