How to Host Helm Charts on GitHub Container Registry
suin
Posted on November 21, 2024
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
- Your token needs the
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
# 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"
# templates/namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: hello-world
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
When prompted, enter your Personal Access Token (PAT) as the password.
2. Package Your Chart
helm package charts/hello-world
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
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
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
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.
Posted on November 21, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.