All Articles

Creating Keratin helm charts

Keratin (keratin.tech) is an open-source authorization microservice implemented in golang. I wanted to play with it to evaluate if it can be useful for my hobby projects. First I tried to find an existing helm chart to deploy it but unfortunately wasn’t able to find one.

So I tried to create and here what I’ve got as a result: https://github.com/keratin/helm-charts.

When creating a helm chart it might be a little confusing what to start with. You can start with preparing a set of k8s configuration files for deployment, service, ingress controller and after that generalize them to the templates. Another way is to start right away with the dummy chart created with helm create command. This is convenient as you can reuse lots of trivial code from that dummy template and customize what you need.

Currently, there are 2 versions of chart format (v1 and v2) supported by helm2 and helm3 respectively. But, to be honest, the difference is not that huge. First, the way you list dependencies is different (in a separate file or directly in the Chart.yaml). Plus the distinction between applications and libraries is a new thing supported only by the format of version 2.

When you complete the chart of its part you can validate it with helm lint or compile templates with helm template command. But of course, nothing would prove that your chart works better then trying it at the real cluster. A nice discovery for me was the fact that you can use required function when you use the variable to force chart users to specify it.

While developing the chart you can deploy it form the source directory (don’t forget to run helm dep up to install dependencies in that case) but for distribution, you need to package it and provide a public URL to download it.

The easiest option for open-source charts is GitHub Pages. I’ve created a separate repository with GitHub Pages enabled for the master branch to host my packages charts: https://github.com/obukhov/keratin-helm-repo.

To create the package you can just run helm package <path> with the path pointing to the chart source folder. The file will be automatically named accordingly with the chart name and version. Move this file to the GitHub Pages enabled repository (in the subfolder with chart name). And finally, run the following command to generate chart index file:

helm repo index <chart folder name> --url <base url>

Base url for github pages follows the template:

https://<user>.github.io/<repo name>/<chart folder name>

That’s it. Now the repository can be added and chart can be installed from it:

helm repo add keratin https://keratin.github.io/helm-repo/charts/

helm upgrade --install <release name> keratin/keratin-authn-server

The next logical step would be to add your repository to the index of hub.helm.sh as described here: https://github.com/helm/hub/blob/master/Repositories.md to make it easier to find by other people.