Running Helm Charts on GitHub Pages

When you’re dealing with various components of an application, managing the associated Kubernetes resources can get quite complex. This is where custom Helm charts come into play, offering a practical solution to streamline this process.

GitHub Pages simplifies the task of hosting Helm charts, providing a workflow that automates the creation and publishing of your charts to a centralized location, complete with versioning support. This workflow is tailored to support a straightforward versioning scheme and manage dependency builds efficiently.

You can find the source code and workflow definition at https://github.com/garunski-co/scry-helm-charts. For guidance on setting up your repository for GitHub Pages, the https://github.com/helm/chart-releaser-action is a helpful resource.

The procedure for publishing new charts or updating existing ones is quite direct:

  1. Install Helm: Make sure Helm is installed on the Actions runner to manage your charts and dependencies.

  2. Manage Chart Dependencies: Ensure all chart dependencies are installed. This involves going through all the Chart.yaml files, checking for dependencies, and then using the repository value in each dependency to add the chart repo to Helm. Here’s a handy command to get you started:

find . -type f -name "Chart.yaml" \
-exec grep -H "dependencies:" \
{} \; -exec grep -H "repository:" \
{} \; | awk -F "repository:" '/repository:/ { sub(/^[ \t]+/, "", $2); sub(/[ \t]+$/, "", $2); print "helm repo add chart "NR, $2 }' \
| sh
  1. Handle Versioning: This repository is primarily for internal use, so we keep versioning simple. Each new commit generates a new Minor Revision.
grep -rl 'REPLACE_MINOR_REVISION' */**/Chart.yaml | \
xargs sed -i 's/REPLACE_MINOR_REVISION/${{ github.run_number }}/g'

This method works well for internal tools and ensures smooth management. However, you might run into a small issue: the version in Chart.yaml is set as 1.0.REPLACE_MINOR_REVISION, which can cause Helm to raise complaints when working on the charts locally. Not to worry though, this is a minor hiccup during development and can be fixed with a better replacement script.

  1. Build Dependencies: Make sure to execute all associated dependency builds:
find . -name Chart.yaml -exec sh -c 'grep -q "dependencies:""{}" && cd "$(dirname "{}")" && helm dependency build'
  1. Publish the Charts: Finally, run the chart releaser action to publish the charts, generate the index.yaml for the chart repository, and trigger the GitHub Pages build.

Looking ahead, there’s a clear opportunity to refine the workflow, particularly in streamlining the versioning process within Chart.yaml and implementing efficient cleanup protocols for outdated releases. Ensuring that version updates are automated, accurate, and consistent with codebase changes will significantly enhance the management and usability of the charts. Additionally, establishing a routine for retiring older chart releases will contribute to a cleaner and more navigable repository.