Session 2: Creating and Hosting Custom Helm Charts
- ✅ Create your own Helm charts from scratch
- ✅ Customize templates and use values effectively
- ✅ Host charts on GitHub as a Helm repository
🛠️ Step 1: Create a Custom Chart
helm create nginx-demo
cd nginx-demoThis creates the following structure:
nginx-demo/
├── charts/
├── Chart.yaml
├── templates/
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── hpa.yaml
│ ├── ingress.yaml
│ ├── service.yaml
│ ├── configmap.yaml
│ └── tests/
└── values.yamlNOTES.txt in a Helm Chart
NOTES.txt is used to display post-installation instructions to users after a Helm chart is installed.
When a user runs:
helm install myapp ./mychartHelm automatically prints the content of templates/NOTES.txt.
This file is typically used to show:
- Application access URLs
- Login credentials
- Verification commands
- Port-forward instructions
Examples
Thank you for installing {{ .Chart.Name }}!
Your release name is: {{ .Release.Name }}
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ .Chart.Name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME 8080:80 --namespace {{ .Release.Namespace }}
2. Access the application at:
http://127.0.0.1:8080
3. To check the status of the deployment:
kubectl get pods -n {{ .Release.Namespace }}
Enjoy using {{ .Chart.Name }}!Understanding _helpers.tpl in Helm Charts
_helpers.tplis a file used in Helm charts to define reusable template helpers.These helpers are small template functions that can be reused across multiple template files in the chart.
The file is usually located at: mychart/templates/_helpers.tpl
Using GitHub as a Helm Chart Repository
GitHub can be used to host Helm charts by serving them through GitHub
Pages.
Helm requires a repository to contain an index.yaml file and packaged
chart files.
A valid Helm repository must contain:
index.yaml
chart-name-version.tgz
Example repository structure:
helm-repo/
├── index.yaml
├── mychart-0.1.0.tgz
Step 1: Create a Helm Chart
Create a new Helm chart.
helm create mychartPackage the chart.
helm package mychartOutput:
mychart-0.1.0.tgz
Step 2: Generate Repository Index
Generate the Helm repository index.
helm repo index .This creates:
index.yaml
Directory structure should now look like:
helm-repo/
├── index.yaml
├── mychart-0.1.0.tgz
Step 3: Push Files to GitHub
Create a new GitHub repository.
Example:
helm01.repo
Push the following files to the repository:
index.yaml
mychart-0.1.0.tgz
Example commands:
git init
git add .
git commit -m "Add Helm chart repository"
git branch -M main
git remote add origin https://github.com/<username>/helm01.repo.git
git push -u origin mainStep 4: Enable GitHub Pages
Go to the repository settings.
Settings → Pages
Select:
Source: Deploy from a branch
Branch: main
Folder: / (root)
Your Helm repository will be available at:
https://<github-username>.github.io/<repository-name>/
Example:
https://nirpendra83.github.io/helm01.repo/
Step 5: Add the Helm Repository
Add the GitHub repository to Helm.
helm repo add tree https://nirpendra83.github.io/helm01.repo/Update the repository list.
helm repo updateStep 6: Verify Helm Repository
Check available charts.
helm search repo treeExample output:
NAME CHART VERSION APP VERSION DESCRIPTION
tree/mychart 0.1.0 1.0 Example Helm chart
Step 7: Install Chart from GitHub Repository
Install the chart.
helm install demo tree/mychartCheck deployment:
kubectl get podsUpdating the Helm Repository
Whenever a new chart version is added:
- Package the chart again
helm package mychart- Regenerate the index
helm repo index .- Commit and push changes
git add .
git commit -m "Update Helm chart"
git pushSummary
Using GitHub as a Helm repository involves the following steps:
- Create a Helm chart
- Package the chart
- Generate
index.yaml - Push files to GitHub
- Enable GitHub Pages
- Add the repository using
helm repo add
Example Helm repository URL:
https://nirpendra83.github.io/helm01.repo/
Install chart:
helm install demo tree/mychartBest Practices
- Use semantic versioning for charts
- Always update
index.yaml - Keep chart packages (
.tgz) in the repository - Use GitHub Pages instead of GitHub HTML URLs
ChartMuseum – Helm Chart Repository Server
ChartMuseum is an open-source Helm Chart Repository server that allows you to store, manage, and distribute Helm charts.
It works similarly to a Docker Registry, but instead of container images it stores Helm chart packages (.tgz).
ChartMuseum allows teams to create private Helm repositories for internal Kubernetes deployments.
Why Use ChartMuseum
While Helm charts can be hosted on GitHub Pages, ChartMuseum is preferred for enterprise environments because it provides more control and automation.
Key Benefits
- Private Helm chart repository
- HTTP API for chart uploads
- Chart version management
- CI/CD integration
- Multiple storage backend support
Supported storage backends:
- Local filesystem
- AWS S3
- Google Cloud Storage
- Azure Blob Storage
- MinIO
ChartMuseum Architecture
Typical workflow:
Developer
│
│ helm push
▼
ChartMuseum Server
│
│ stores charts
▼
Storage Backend
│
▼
Helm Clients
Helm clients retrieve charts using:
helm repo add
helm install
Installing ChartMuseum (Docker)
The easiest way to run ChartMuseum is using Docker.
docker run -d \
-p 8080:8080 \
-e STORAGE=local \
-e STORAGE_LOCAL_ROOTDIR=/charts \
-v $(pwd)/charts:/charts \
ghcr.io/helm/chartmuseum:latestChartMuseum will start on:
http://localhost:8080
Verify Chart Repository
Open the following URL in a browser:
http://localhost:8080/index.yaml
Example output:
apiVersion: v1
entries:
mychart:
- version: 0.1.0Add ChartMuseum Repository to Helm
Add the repository to Helm:
helm repo add myrepo http://localhost:8080Update Helm repositories:
helm repo updateCreate and Package a Helm Chart
Create a chart:
helm create mychartPackage the chart:
helm package mychartOutput:
mychart-0.1.0.tgz
Upload Chart to ChartMuseum
Upload the chart using curl:
curl --data-binary "@mychart-0.1.0.tgz" http://localhost:8080/api/chartsChartMuseum will automatically update the repository index.
Verify Uploaded Charts
Check available charts:
helm search repo myrepoExample output:
NAME CHART VERSION APP VERSION DESCRIPTION
myrepo/mychart 0.1.0 1.0 Example chart
Install Chart from ChartMuseum
Install the chart:
helm install demo myrepo/mychartVerify deployment:
kubectl get podsList Charts in ChartMuseum
You can check charts using the API:
http://localhost:8080/api/charts
Example response:
{
"mychart": [
{
"version": "0.1.0"
}
]
}Delete a Chart
Delete a specific chart version:
curl -X DELETE http://localhost:8080/api/charts/mychart/0.1.0ChartMuseum with CI/CD
ChartMuseum integrates easily with CI/CD tools such as:
- GitLab CI
- Jenkins
- GitHub Actions
- ArgoCD
- Tekton
Typical pipeline step:
helm package mychart
curl --data-binary "@mychart-0.1.0.tgz" http://chartmuseum/api/charts
Best Practices
- Use semantic versioning for Helm charts
- Automate chart publishing via CI/CD
- Use S3 or object storage for production
- Secure ChartMuseum using authentication
Summary
ChartMuseum provides an easy way to host private Helm repositories.
Main workflow:
- Create Helm chart
- Package chart
- Upload chart to ChartMuseum
- Add repository to Helm
- Install charts from the repository
Example commands:
helm repo add myrepo http://localhost:8080
helm install demo myrepo/mychart