In this article, I'll show you how to create your own private Helm Chart repository using a GitHub private repository. This approach is perfect for personal or team use.
Why Use GitHub as a Helm Chart Repository?
While this setup might not be ideal for production environments, it's excellent for development and testing purposes because:
- You can securely manage private Kubernetes manifests
- It's easy to share Helm Charts within your team
- No additional infrastructure management is required
Prerequisites
You'll need:
- A GitHub private repository
- A GitHub Personal Access Token
- For Classic Token: requires
repo
scope - For Fine-grained Token: needs read access to "Contents"
- For Classic Token: requires
- Helm CLI installed
-
git
command line tool
Sample Chart Overview
For this tutorial, we'll use a minimal hello-world
chart. Here's what it looks like:
# 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
This chart is intentionally simple:
- It creates a namespace called
hello-world
- It has no configurable values
- When deployed, it creates a new namespace in your Kubernetes cluster
While real-world charts are typically more complex, we're keeping it minimal to focus on the repository setup process.
Step-by-Step Guide
1. Package Your Chart
First, let's package our hello-world
chart:
cd private-repo
helm package hello-world/
This creates hello-world-0.1.0.tgz
, containing our Chart.yaml and templates/namespace.yaml.
2. Generate the Index File
Create an index file to tell Helm about available charts:
helm repo index .
This generates index.yaml
with content like:
apiVersion: v1
entries:
hello-world:
- apiVersion: v2
appVersion: 1.0.0
created: "2024-11-21T10:00:00.000000000Z"
description: A simple Helm chart that creates hello-world namespace
digest: 1234567890abcdef... # actual hash will vary
name: hello-world
type: application
urls:
- hello-world-0.1.0.tgz
version: 0.1.0
3. Push to GitHub
Upload everything to GitHub:
git init
git add .
git commit -s -m "Initial commit"
git branch -M main
git remote add origin git@github.com:your-username/repo-name.git
git push -u origin main
4. Configure Helm
Add the repository to your local Helm configuration:
helm repo add --username your-github-username --password your-github-token private-repo 'https://raw.githubusercontent.com/your-username/repo-name/main'
Update the repository information:
helm repo update
5. Verify Setup
Check if your chart is discoverable:
helm search repo private-repo/hello-world
You should see something like:
NAME CHART VERSION APP VERSION DESCRIPTION
private-repo/hello-world 0.1.0 1.0.0 A simple Helm chart that creates hello-world namespace
Using Your Chart
Before installing, it's good practice to do a dry-run:
helm install test-hello private-repo/hello-world --dry-run
Output:
# Source: hello-world/templates/namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: hello-world
If everything looks good, proceed with the installation:
helm install hello-world private-repo/hello-world
Successful installation output:
NAME: hello-world
LAST DEPLOYED: Thu Nov 21 14:45:40 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
Verify:
kubectl get namespace hello-world
Repository Structure
Your final repository structure should look like this:
.
├── README.md
├── index.yaml # Helm repository index
├── hello-world-0.1.0.tgz # Packaged chart
└── hello-world/ # Chart source
├── Chart.yaml # Chart metadata
└── templates/ # Kubernetes manifest templates
└── namespace.yaml # Namespace manifest
That's it! You now have your own private Helm Chart repository. This setup is perfect for sharing charts within your team and managing versions effectively.
Feel free to reach out in the comments if you have any questions or run into issues!
Top comments (0)