The Ops Community ⚙️

Joseph D. Marhee
Joseph D. Marhee

Posted on

Using Git for a Helm Chart Repo

Git Repos can be used to store Helm Charts, and can be imported by the Helm CLI to install charts to your Kubernetes cluster. My repo of charts for this example can be found here.

Assume you create a repo with the following structure, a repo named charts:

 ~/repos/charts (main) $ ls
assets      charts  
Enter fullscreen mode Exit fullscreen mode

where charts subdirectory contains all of your Helm chart templates like you might normally normally expect, and assets where you are going to store the Helm tar.gz packages we will create that the Helm CLI will actually pull and install.

In my case, my repo contains the following charts:

~/repos/charts (main) $ ls charts
sysdepot-authoritative-dns  sysdepot-logging
sysdepot-bitbucket      sysdepot-postgres
Enter fullscreen mode Exit fullscreen mode

and I want to publish a chart for sysdepot-logging, so I will package it:

helm package charts/sysdepot-logging -d assets/sysdepot-logging
Successfully packaged chart and saved it to: charts/assets/sysdepot-logging-0.1.0.tgz
Enter fullscreen mode Exit fullscreen mode

but before committing this archive and use my Git repo with Helm, I have to create an index so Helm can actually know where in my Git repo to find the chart bundle:

helm repo index .
Enter fullscreen mode Exit fullscreen mode

which creates an index.yaml file:

apiVersion: v1
entries:
  sysdepot-logging:
  - apiVersion: v2
    appVersion: 1.16.0
    created: "2024-05-09T10:08:39.866741-05:00"
    description: A Helm chart for Kubernetes
    digest: ac545bd91ad481795556a331b15bd4871e598d1e89d0c54ed338ab9afb2b8771
    name: sysdepot-logging
    type: application
    urls:
    - assets/sysdepot-logging-0.1.0.tgz
    version: 0.1.0
generated: "2024-05-09T10:08:39.866166-05:00"
Enter fullscreen mode Exit fullscreen mode

in the root of my repo that points to the archive in my assets directory.

So, with that created, I commit my charts, and the archives, and the index file to my git repo as I would with any git repository (git add, commit, etc.)

For a Github repo, for example, you can add it to Helm using the following format:

helm repo add jmarhee https://raw.githubusercontent.com/{your_username}/{your_repo}/{target_branch}/
Enter fullscreen mode Exit fullscreen mode

then after helm repo update, you can install charts from your new repo.

Top comments (0)