Let's discuss how we can host our helm charts on GitHub pages and allow other people to use our charts on ArtifactHub. Before understanding the process we will try to understand these terms in the simplest form
Helm charts is the way you templatize your Kubernetes resources that you want to deploy. If you want to create kubernetes resource in multiple clusters (or even in the same cluster)with different values you create a template for the resources and package it. This package is known as helm chart.
GitHub Pages is a feature of GitHub that allows you to create a website or a web page hosted on GitHub servers. If you have a simple index.html file then you can host this HTML file using GitHub provided domain name which generally goes in the format username.github.io . It’s a way for you to share your work or showcase your projects online without the need for a separate web hosting service. In our case we will host our helm charts on GitHub Pages.
index.html
username.github.io
ArtifactHub is a web based platform that acts as a central repo for various software distributions like helm charts, OPA etc. Once we have created our helm chart, hosted it on GitHub pages, we will make it discoverable to the community by showcasing it on Artifacthub.
ArtifactHub does not host the Helm charts itself, but rather serves as a registry for Helm chart repositories. Developers can publish their Helm charts to their preferred repository, such as GitHub, GitLab, or Bitbucket, and then register their repository with ArtifactHub.
Now we will see how we can leverage the Pages features of GitHub to host our application's helm charts. In this example I am taking a sample helm charts but you can also use your own customized helm charts in the same way
We will start by creating a sample helm chart
helm create sample-nginx
We will create a public GitHub repo where we will host the charts.
charts
main
$ tree ..├── README.md└── charts └── sample-nginx ├── Chart.yaml ├── charts ├── templates │ ├── NOTES.txt │ ├── _helpers.tpl │ ├── deployment.yaml │ ├── hpa.yaml │ ├── ingress.yaml │ ├── service.yaml │ ├── serviceaccount.yaml │ └── tests │ └── test-connection.yaml └── values.yaml
We have created a repo and it is hosted here:
Once our charts are in the main branch we need to create a pipeline that can create a GitHub release. This GitHub release will in return publish our charts. For this we require a token to be created with specific set of permissions which will then be used in our pipeline to release charts.
Read and write
Contents
We can use GitHub Pages to host our website directly on GitHub (statically).
gh-pages
<!DOCTYPE html><html><head> <title>Sample charts</title> <style> .chart { width: 400px; height: 300px; margin: 20px; border: 1px solid #ccc; box-shadow: 2px 2px 5px #ccc; display: inline-block; vertical-align: top; padding: 10px; box-sizing: border-box; font-size: 14px; line-height: 1.5; } .chart h3 { margin-top: 0; font-size: 18px; font-weight: bold; } .chart p { margin: 0; } </style></head><body> <h1>Sample charts</h1> <div class="chart"> <h3>Chart 1</h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer euismod diam et purus hendrerit mollis.</p> <!-- add your chart code here --> </div> <div class="chart"> <h3>Chart 2</h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer euismod diam et purus hendrerit mollis.</p> <!-- add your chart code here --> </div> <div class="chart"> <h3>Chart 3</h3> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer euismod diam et purus hendrerit mollis.</p> <!-- add your chart code here --> </div></body></html>
In the previous steps we discussed about the pipeline which will use the Access token to create a GitHub Release. You can chose any preferred tool for performing this task but I will chose GitHub Actions for this. GitHub Actions is yet another tool natively supported in GitHub to perform CI/CD tasks.
Before creating the pipeline we will create a secret variable to pass the token we created in the previous task.
This token can now be used in the pipeline to push the releases.
Now we will create the GitHub Action pipeline
.github/workflows
release.yaml
name: Release Chartson: push: branches: - mainjobs: release: permissions: contents: write # to push chart release and create a release (helm/chart-releaser-action) runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v3 with: fetch-depth: 0 - name: Configure Git run: | git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - name: Set up Helm uses: azure/setup-helm@v3.5 with: version: v3.9.2 - name: Run chart-releaser uses: helm/chart-releaser-action@v1.5.0 env: CR_TOKEN: "${{ secrets.HELM_RELEASE_TOKEN }}"
This pipeline is very simple. Let’s understand it very quickly
name
on
jobs
write
steps
actions/checkout@v3
action
azure/setup-helm
helm/chart-releaser-action
HELM_RELEASE_TOKEN
index.yaml
Now we will make very small change in the README.md file of the repository in the main branch so that the pipeline is triggered. When I pushed the changes I am able to see a small orange dot which signifies that a pipeline is running
README.md
pages build and deployment
gh-pages branch
To test if our helm registry is created successfully or not
minikube
# add the repohelm repo add sample-charts https://dunefro.github.io/sample-charts/helm repo update# install the chartshelm upgrade --install test-nginx sample-charts/sample-nginx# check pods$ kubectl get podsNAME READY STATUS RESTARTS AGEtest-nginx-sample-nginx-b95bb4f46-tbppn 1/1 Running 0 30s
Our charts are working fine.
Now we will try to see how we can set up an account on ArtifactHub so that we can show our helm charts to the community. You might also find some other community charts like
Now our charts are hosted. We need to make sure they can be used from other developers via ArtifactHub.
We can see our repo being created and once ArtifactHub is able to pull the data it will also start to reflect in the searches. Now we want to apply the verified publisher tag something like this
For this we need to add a file artifacthub-repo.yml in the gh-pages branch as a metadata file which will be read by ArtifactHub in return verifying that we are the owner of the registry.
artifacthub-repo.yml
repositoryID: 67d52f16-b102-4661-bfa5-9e6694587e24owners: # (optional, used to claim repository ownership) - name: Vedant Pareek email: dunefro@gmail.com
This is the same way we used to host our public helm charts at Truefoundry. TrueFoundry is MLOps, LLMOps platform that eases out the entire lifecycle journey of bringing the machine learning models from development to production. It takes into considerations all the pain points throughout the journey of Machine learning lifecycle to bring an ease and comfort while building models.
Join AI/ML leaders for the latest on product, community, and GenAI developments