In this article, we are going to learn how to create Helm repository using GitHub pages to publish your Helm chart. Helm helps you to manage Kubernetes applications. Helm uses a packaging format called charts. A chart is a collection of files that describe a related set of Kubernetes resources. A single chart might be used to deploy your application to multiple environments such as test, staging, and production using a different set of values for each environment.

Create GitHub Repo

Before you begin this guide you’ll need to create a GitHub repository to store your Helm chart. You can create a new repository by clicking the New repository button in your GitHub account. You can name the repository as you wish. In this example, I have named it as "helm-github-pages-repo". Now you need to clone this repo in to your local directory.

Create Helm Chart

Now you need to create a Helm chart. You can create a Helm chart or you can use an existing Helm chart. In this example, I am going to use an existing Helm chart. I am going to use the "tomcat-chart" Helm chart. You can find the Helm chart in the following GitHub repository.

Packaging Helm Chart

Now you need to package the Helm chart. You can use the following command to package the Helm chart. To package the Helm chart you need to run the following command in the root directory of the directory.

1
2
3
4
helm package <chart-directory> --version <version-number>

### Example command need to package the Helm chart which cloned from Create Helm Chart step
helm package ./chart/tomcat-chart --version v1.0.0

Creating Helm Chart Repository

Now you need to create a Helm chart repository. You can use the following command to create a Helm chart repository. To create a Helm chart repository you need to run the following command in the root directory of the directory.

1
2
3
4
5
### This command will completely rebuild the index.yaml file from scratch, including only the charts that it finds locally, and ignoring any previously packaged charts.
helm repo index .

### Above command with --merge flag to incrementally add new charts to an existing index.yaml
helm repo index --merge index.yaml .

This command will create a file called “index.yaml” in the root directory of the directory. This file contains the information about the Helm chart repository.

Pushing Helm Chart to GitHub

Now you need to push the Helm chart to GitHub. You can use the following command to push the Helm chart to GitHub. To push the Helm chart to GitHub you need to run the following command in the root directory of the directory.

1
2
3
git add .
git commit -m "feat: Add Helm chart to GitHub"
git push origin master

Configuring GitHub Pages

Now you need to configure GitHub pages. You can use the following steps to configure GitHub pages.
  • Navigate to the "Settings" tab in your GitHub repository
  • Scroll down to the "GitHub Pages" section from the left sidebar
  • Click the "Source" dropdown and select the "Deploy from a branch" option
  • Click the "Source" dropdown and select the "main" branch from the dropdown
  • Click the "Save" button
  • Now you can see the URL of the GitHub pages. You can use this URL to access the Helm chart repository.

    Install Helm chart

    Now you can add the Helm chart repository using the following command.

    1
    2
    3
    4
    helm repo add <repo-name> <github-pages-url>

    ###Example
    helm repo add tomcat-chart https://dinushchathurya.github.io/helm-github-pages-repo/

    Now you can install the Helm chart using the following command.

    1
    2
    3
    helm install <release-name> <repo-name>/<chart-name> --version <version>

    helm install release-one tomcat-chart/tomcat-chart --version v1.0.0

    Everytime you add new chart tar.gz file, update index.yaml file and push changes to github repo, it’ll automatically update the github page with new chart version. You can update your local chart repo using helm repo update and following helm install command with new version.

    Conclusion

    In this article, we learned how to create Helm repository using GitHub pages to publish your Helm chart. You can find the all the related commands for this tutorial from here. If you have any issue regarding this tutorial, mention your issue in the comment section or reach me through my E-mail.

    Happy Coding