Create your own Helm Chart Repository using GitHub Pages

Sajid Hussain
4 min readNov 8, 2020

Recently I have been going through this awesome package manager for Kubernetes called Helm. Its a great tool for managing the Kubernetes manifests whenever we are dealing with a large number of microservices. What Helm does is, it groups all the Kubernetes manifests required for a microservice into a folder/chart. And then it helps us manage the lifecycle of the chart. Thus abstracting the multiple Kubernetes manifests associated with a single microservice from the developers.

Similar to the very popular Docker hub, Helm also has a publicly accessible Helm hub. Anybody can download charts from the Helm hub and use them, just like we do with Docker hub. There are many other publicly accessible Helm Chart Repositories too, either managed by big organisations or the open source community. But it’s always great to have a custom repository that we can use as our own Helm Chart Repository. It helps us share our charts with friends and peers by just sharing the link to the Helm Chart Repository. So, that whenever we update our charts or add new charts, interested folks can access them by just updating the chart repository in their local machines using helm repo update .

Let’s now look at the steps involved in creating our own Helm Chart Repository :

  • Chart Repository : A chart repository is just an HTTP server that houses an index.yaml file and our packaged charts. So, we have plenty of options to host our chart repository, we can either use Cloud Object Storage or GitHub Pages or JFrog Artifactory or our own web server. We just need to serve some static content that’s it. Here we are using the GitHub Pages approach.
  • Create GitHub repo : The first thing is to create a new GitHub repo and then just for following the conventions, lets have a separate branch called gh-pages. All our static content will go into this branch.
  • Update GitHub repo settings : Now, we need to update the settings of the repo to configure the GitHub page. The Source of the GitHub page should be pointing to the gh-pages branch and should be serving the /root dir. We can also find our GitHub page URL from this settings section itself. This would be our chart repository URL.
  • Git clone : Let’s clone the repo to our local machine.
  • Helm package : Package the helm chart that we want to upload to our repo.

Note : if we don’t have a helm chart ready, we can just create a sample one using helm create my-chart . I have a helm chart named webapp ready with me, so I’m using it.

helm package ./webapp
  • Create a new folder and copy the packaged chart into it.
> mkdir sajid-helm-charts
> mv webapp-1.0.0.tgz sajid-helm-charts/
  • Chart repo index creation : Next we have to create the index.yaml file. A valid chart repository must have an index file. The index file contains information about each chart in the chart repository.
helm repo index sajid-helm-charts --url https://joon88.github.io/sajid-helm-charts/

Note : The helm repo index command will generate an index file based on the given local directory that contains the packaged charts.

  • Git push : Copy or move the index.yaml and the packaged charts to the local GitHub repo, git add, commit and push them to the remote.
  • That’s it, we have successfully pushed a chart to our chart repository. Let’s now add this new repository to our local Helm CLI and install the Helm chart in it to our cluster.

Note : helm always uses the current kubectl context, so before doing helm install we have to make sure that our kubectl context is set to the desired cluster.

Adding the custom chart repo to helm CLI

❯ helm repo add sajid-helm-charts https://joon88.github.io/sajid-helm-charts/"sajid-helm-charts" has been added to your repositories

List all chart repos to verify the addition

❯ helm repo listNAME                URLstable              https://kubernetes-charts.storage.googleapis.com/sajid-helm-charts   https://joon88.github.io/sajid-helm-charts/

Search for the chart

❯ helm search repo sajid-helm-chartsNAME                     CHART VERSION APP VERSION DESCRIPTIONsajid-helm-charts/webapp 1.0.0         1.16.0      A Helm chart for Kubernetes

Install the chart to a cluster

❯ helm install sajid-helm-charts/webapp --generate-nameNAME: webapp-1604839594LAST DEPLOYED: Sun Nov  8 18:16:38 2020NAMESPACE: defaultSTATUS: deployedREVISION: 1NOTES:1. Get the application URL by running these commands:export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services webapp-1604839594)export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")echo http://$NODE_IP:$NODE_PORT

For more information its always great to follow https://helm.sh/.

--

--

Sajid Hussain

Trying to grow every single day, and be better than yesterday.