DEV Community

suin
suin

Posted on

How to Host Helm Charts on GitHub Container Registry

Recently, I've been working more with application management in Kubernetes environments, which led me to think deeply about Helm chart management. Today, I'll show you how to host Helm charts using GitHub Container Registry (GHCR). What makes GHCR particularly attractive is its free private registry feature, making it an ideal choice for personal projects or small team collaborations.

Prerequisites

You'll need:

  • Helm
  • A GitHub account with a Classic Personal Access Token
    • Your token needs the write:packages scope
    • Note: Fine-grained permissions aren't currently supported for GHCR

Our Example Chart

For this tutorial, we'll use a minimalist chart that creates a hello-world namespace. Here's our chart structure:

charts/hello-world/
├── Chart.yaml
├── templates/
│   └── namespace.yaml
Enter fullscreen mode Exit fullscreen mode
# Chart.yaml
apiVersion: v2
name: hello-world
description: A simple Helm chart that creates hello-world namespace
type: application
version: 0.1.0
appVersion: "1.0.0"
Enter fullscreen mode Exit fullscreen mode
# templates/namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: hello-world
Enter fullscreen mode Exit fullscreen mode

Publishing to GHCR

1. Log into GitHub Container Registry

First, log in using the Helm CLI:

helm registry login ghcr.io -u YOUR_GITHUB_USERNAME
Enter fullscreen mode Exit fullscreen mode

When prompted, enter your Personal Access Token (PAT) as the password.

2. Package Your Chart

helm package charts/hello-world
Enter fullscreen mode Exit fullscreen mode

This creates a hello-world-0.1.0.tgz file.

3. Push to GHCR

helm push hello-world-0.1.0.tgz oci://ghcr.io/YOUR_GITHUB_USERNAME
Enter fullscreen mode Exit fullscreen mode

That's it! Simple and straightforward.

Using Your Published Chart

To install the chart from GHCR:

helm install hello-world oci://ghcr.io/YOUR_GITHUB_USERNAME/hello-world --version 0.1.0
Enter fullscreen mode Exit fullscreen mode

Cleanup

After testing, you can clean up with these commands:

# Uninstall the Helm release
helm uninstall hello-world

# Delete the created namespace
kubectl delete namespace hello-world

# Remove the local package file
rm hello-world-0.1.0.tgz
Enter fullscreen mode Exit fullscreen mode

Why GHCR?

GitHub Container Registry offers several advantages:

  • Free private registries
  • Seamless GitHub integration for easier management
  • OCI standard compatibility

Additionally, having your Helm charts and source code in the same ecosystem simplifies your DevOps workflow. The ability to manage access through GitHub's familiar interface is a significant bonus for teams already using GitHub for their development work.

Wrapping Up

Hosting Helm charts on GitHub Container Registry is a straightforward process that provides a robust solution for chart management. Whether you're working on personal projects or collaborating with a small team, GHCR offers a reliable, cost-effective platform for your Helm charts.

Give it a try and let me know how it works for your use case! Feel free to share your experiences or ask questions in the comments below.

Top comments (0)