How to share Helm chart via Helm repository hosted on Github pages
Helm is a powerful tool to manage the Kubernetes workload’s release management. In my last blog, I have discussed Helm charts — what, why and how in detail. So if you are new to the helm, I request to read my previous post.
Recently I am working on an open-source project named Kube-Curator. And to share its helm chart with the community I need to share it via a helm repository.
So let’s see how can we share Kube-Curator step by step and start with the Helm repository itself.
Helm Repository — Helm repository is a simple HTTP server that can host Helm charts .tar file and an index.yaml file. As simple as that.
Various ways to create helm repo — There are several options available when it comes to hosting a helm repository. Like:
- Google cloud platform
- JFrog Artifactory
- Github Pages etc
Simplest one from the above list is GitHub pages. Here we will be creating a helm repository using GitHub pages. I will try to write about the other two options later.
Step 1. Prepare Helm chart
kube-curator
├── charts
├── Chart.yaml
├── templates
│ ├── configMap.yaml
│ ├── cron.yaml
│ ├── roleBinding.yaml
│ ├── roles.yaml
│ └── serviceAccount.yaml
└── values.yaml
This is my helm chart for Kube-Curator.
Step 2. Create helm package(.tar file)
$ helm package kube-curator
Successfully packaged chart and saved it to: /home/rsingh/Desktop/Go-Project/kube-curator-1.0.0.tgz
The above command created a helm package for my project. Now all I need to do is to share it with Helm repository. Wait! First, we need to create a Helm repository.
Step 3. Create a GitHub repository and clone it.
$ git clone https://github.com/rvgud/kube-curator.git
Cloning into 'kube-curator'...
warning: You appear to have cloned an empty repository
$ cd kube-curator
Step 4. Create a branch named gh-pages and add index.html file
$ git checkout -b gh-pages
Switched to a new branch 'gh-pages'$ touch index.html$ git add .$ git commit -m "Added index.html file"
[gh-pages (root-commit) 544bc54] Added index.html file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 index.html$ git push --set-upstream origin gh-pages
Counting objects: 3, done.
Writing objects: 100% (3/3), 226 bytes | 226.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:rvgud/kube-curator.git
* [new branch] gh-pages -> gh-pages
Branch 'gh-pages' set up to track remote branch 'gh-pages' from 'origin'.
Step 5. Access Github pages.
Go to the Settings tab of your Github repository and scroll down till Github pages. Here you will see a link, for me it is https://rvgud.github.io/kube-curator/.
Let’s just test this link using curl.
$ curl https://rvgud.github.io/kube-curator/
If the above command executes successfully this means our helm repository HTTP server is live via Github pages.
Step 6. Move the package created in Step 2 to this repository and push.
$ mv kube-curator-1.0.0.tgz kube-curator/
$ helm repo index kube-curator/ --url https://rvgud.github.io/kube-curator/
$ git add .
$ git commit -a -m "Uploading helm chart"
$ git push
So first I moved my helm chart to my GitHub repository. Next, I fired a helm command as a Helm repo index. So let’s what it is. This command takes input as your local path of Helm chart package folder and remote GitHub pages URL. And In the end, it will create an index.yaml file. Which for me looks like this:
$ cat kube-curator/index.yaml
apiVersion: v1
entries:
kube-curator:
- apiVersion: v1
appVersion: "1.0"
created: 2019-12-16T12:17:12.71623064+05:30
description: A Helm chart for kube-curator project.
digest: 2b70eb1a2292660ef92b63c53b2d859d76a2291d2092ba5a8c7d028a4d413021
name: kube-curator
urls:
- https://rvgud.github.io/kube-curator/kube-curator-1.0.0.tgz
version: 1.0.0
generated: 2019-12-16T12:17:12.715865054+05:30
That’s it. My helm repository is ready to share the Kube-Curator Helm chart.
Let’s see how can I access my Helm repository to download Helm chart.
First, I have to add this repo URL to Helm repo list in my (or anyone who wants to download this helm chart) laptop.
$ helm repo add kube-curator https://rvgud.github.io/kube-curator/
"kube-curator" has been added to your repositories$ helm repo list
NAME URL
kube-curator https://rvgud.github.io/kube-curator/
Great! My helm repo is live and now I can fetch my helm chart or install my helm chart.
$ helm install kube-curator/kube-curator --name kube-curator
Done.
So this is how we can create and share our helm chart with others. I hope this gives to a sense to start with helm. Please do write your comments and feedback, I would love to hear them. Also, do follow the space Kube-Curator. And I am not able to stop myself by writing about Kube-Curator. Kube-curator is an automatic pod restarter solution. You just give the namespaces name and label to select pods and it will automatically kill the pod and restart them. Sound Interesting? Do check out the Github repository and contribute or share your inputs.
Bye Bye. Happy helming!