Create a public Helm chart repository with GitHub Pages

Mattia Peri
5 min readApr 18, 2019

In the last months I had the opportunity to work on Kubernetes and the ecosystem of tools built around it by the community. These tools aim to help the DevOps guys through all the stages of the Software Lifecycle, from the development phase to the deployment phase. One of these tools is Helm.

What is Helm and a Helm chart repository

Helm, as per official claim, is “The package manager for Kubernetes”.

Indeed Helm really helps handling application deployments on Kubernetes, not only because it simplifies the application release phase but also because Helm makes possible to easily manage variables in the Kubernetes manifest YAML files.

Once the charts are ready and you need to share them, the easiest way to do so is by uploading them to a chart repository. A Helm chart repository is where we host and share Helm packages and any HTTP server will do. Unluckily Helm does not include natively a tool for uploading charts to a remote chart repository server (Helm can serve the local repository via $ helm serve though).

We’ll take advantage of GitHub Pages for the purpose to share our charts.

What is GitHub Pages

GitHub Pages is a static site hosting service provided to you by GitHub, designed to host your pages directly from a GitHub repository. GitHub Pages is a perfect match for our purpose, since everything we need is to host a single index.yaml file along with a bunch of .tgz files.

Why not hosting all this stuff in your own web server? A managed service helps to reduce your operational overhead and risk (think to monitoring, patch management, security, backup services…) so you can focus on code and in what makes your business relevant for your customers.

Step-by-step guide

Please keep in mind that following the instruction below, your Helm charts repository will be public.

Let me guide you through how to implement this solution.

Create a new repository on your Github account (i.e. “helm-chart”):

Follow the link https://github.com/new and login, then create a new git repository as per image:

Since it’s an empty repository, we can’t publish a GitHub Pages site for now, keep the browser tab open for later.

Clone the repository

$ git clone https://github.com/mattiaperi/helm-chart.git && cd helm-chart/
Cloning into ‘helm-chart’…
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.

Create robots.txt

I’d like to avoid bot crawling on my repository, so I add the following robots.txt file:

$ echo -e “User-Agent: *\nDisallow: /” > robots.txt

Create a helm chart from scratch (or copy your own)

As a pre-requisite of this stage, you need to have the Helm CLI installed and initialized. Please find here the instructions in case you haven’t install Helm client yet.

I’m going to use the directory ./helm-chart-sources/ for the sources of our charts. I’m creating a default chart just for testing purposes, you might want to copy into ./helm-chart-sources/ your charts instead:

$ mkdir ./helm-chart-sources && cd ./helm-chart-sources/$ helm create helm-chart-sources/helm-chart-test
Creating helm-chart-sources/helm-chart-test

Lint the chart

As a good habit, helm lint runs a series of tests to verify that
the chart is well-formed:

$ helm lint helm-chart-sources/*

Create the Helm chart package

$ helm package helm-chart-sources/*
Successfully packaged chart and saved it to: /Users/perim/git/helm-chart/helm-chart-test-0.1.0.tgz

Create the Helm chart repository index

According to Helm:

A repository is characterized primarily by the presence of a special file called index.yaml that has a list of all of the packages supplied by the repository, together with metadata that allows retrieving and verifying those packages.

So, everything we need to create is the index.yaml file and the command to do that is:

$ helm repo index --url https://mattiaperi.github.io/helm-chart/ .$ cat index.yaml 
apiVersion: v1
entries:
helm-chart-test:
- apiVersion: v1
appVersion: "1.0"
created: 2019-04-16T11:10:08.729944+02:00
description: A Helm chart for Kubernetes
digest: 35a4e31bfacc496f1b1bce664652916bb8701cc9df77f1b90534f5234ff297a6
name: helm-chart-test
urls:
- https://mattiaperi.github.io/helm-chart/helm-chart-test-0.1.0.tgz
version: 0.1.0
generated: 2019-04-16T11:10:08.729368+02:00

Push the git repository on GitHub

$ git add . && git commit -m “Initial commit” && git push origin master

Configure the “helm-chart” repository as a Github pages site

Now it’s time to publish the contents of our git repository as Github pages. Go back to your browser, in the “settings” section of your git repository, scroll down to Github Pages section and configure it as follow:

Configure helm client

In order to share your brand new repository, everyone interested in your charts need to configure their own Helm client. Also on client side, repositories are managed with the $ helm repo commands:

$ helm repo add myhelmrepo https://mattiaperi.github.io/helm-chart/
“myhelmrepo” has been added to your repositories

Test the Helm chart repository

$ helm search test
NAME CHART VERSION APP VERSION DESCRIPTION
[…]
myhelmrepo/helm-chart-test 0.1.0 1.0 A Helm chart for Kubernetes
[…]

Add new charts to an existing repository

Whenever you need to add a new chart to the Helm chart repository, it’s mandatory for you to regenerate the index.yaml file. The $ helm repo index command will completely rebuild the index.yaml file from scratch, including only the charts that it finds locally, which very likely is our case. However, it worth notice that you can use the --merge flag to incrementally add new charts to an existing index.yaml:

$ helm repo index --url https://mattiaperi.github.io/helm-chart/ --merge index.yaml .

Hope you find these information useful, any feedback or advice for improvements are very well accepted. Let me know if you enjoyed this article by hitting the applause button or leaving a comment below, it would mean a lot.

--

--

Mattia Peri

AWS Certified Solutions Architect | Certified Kubernetes CKAD | Senior DevOps Engineer. Find me professionally: https://www.linkedin.com/in/mattiaperi/