This tutorial shows how to build a minimal custom Helm chart: scaffold it with helm create, remove the default templates, add your own Pod template, set chart metadata in Chart.yaml, and install it on a Kubernetes cluster. The commands above are the short version. The sections below add the file contents, explain what each step does, show how to check that it worked, and fix a few problems in the original commands.
$ sudo -s
$ apt-get install tree -y
$ helm create devopsx
$ cd devopsx/templates/
$ rm -rf deployment.yaml hpa.yaml ingress.yaml service.yaml serviceaccount.yaml
$ vi pod.yaml # https://www.devopsschool.com/blog/kubernetes-pod-example-programs/
$ cd ..
$ vi Chart.yaml
$ cd ..
$ helm install -h
$ helm install devopsx ./devopsx/
Code language: JavaScript (javascript)
Prerequisites
- A running Kubernetes cluster (minikube, kind, k3s or a managed cluster) and a working
kubectl. Check withkubectl get nodes. - Helm 3 or later installed. Check with
helm version. Helm 3 needs no Tiller and uses the same kubeconfig askubectl. - Optional: the
treeutility for viewing the chart layout (sudo apt-get install -y treeon Debian or Ubuntu). - Basic knowledge of Kubernetes Pod manifests. If Helm is new to you, read What is Helm & How it works? first.
Note: Only the apt-get step needs root. Run helm and kubectl as your normal user. The sudo -s in the example above switches you to root, and root usually has no ~/.kube/config, which causes the error Kubernetes cluster unreachable.
What helm create generates
helm create devopsx creates a working sample chart that deploys nginx with a Deployment, Service, optional Ingress, HPA and ServiceAccount. Run tree devopsx to see the layout. The exact file list depends on your Helm version, and newer releases add extra templates, so check it rather than assuming.
devopsx/
โโโ Chart.yaml # chart name, version and metadata
โโโ charts/ # dependent (sub)charts
โโโ templates/
โ โโโ NOTES.txt # text printed after install
โ โโโ _helpers.tpl # reusable named templates (names, labels)
โ โโโ deployment.yaml
โ โโโ hpa.yaml
โ โโโ ingress.yaml
โ โโโ service.yaml
โ โโโ serviceaccount.yaml
โ โโโ tests/
โ โโโ test-connection.yaml
โโโ values.yaml # default configuration values
โโโ .helmignore # files excluded when packagingCode language: PHP (php)
The rm command above removes the five resource templates but leaves NOTES.txt, _helpers.tpl and tests/test-connection.yaml. Keep _helpers.tpl because it gives you consistent names and labels. The test Pod expects a Service that no longer exists, so delete it. Replace NOTES.txt with something simple, because the default one refers to Service and Ingress values.
Build the chart step by step
- Scaffold the chart:
helm create devopsx. - Remove the default resource templates and the test:
cd devopsx/templates && rm -f deployment.yaml hpa.yaml ingress.yaml service.yaml serviceaccount.yaml && rm -rf tests. Runlsafterwards. If your Helm version generated other resource templates, such as an HTTPRoute, delete those too. - Create
templates/pod.yamlwith the template shown in the next section. - Replace
templates/NOTES.txtwith a short message (example below). - Edit
Chart.yamlto set the description, chartversionandappVersion. - Go back to the parent directory and validate:
helm lint ./devopsxandhelm template devopsx ./devopsx. - Install:
helm install devopsx ./devopsx.
The chart files
A hard-coded Pod manifest copied into templates/ will install, but it isn't really a chart yet: you can't change the image or install the chart twice without editing the file. The template below takes its name and labels from _helpers.tpl and the image from values.yaml, so each release gets a unique name and can be configured at install time.
# devopsx/templates/pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: {{ include "devopsx.fullname" . }}
labels:
{{- include "devopsx.labels" . | nindent 4 }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCPCode language: PHP (php)
include "devopsx.fullname" .produces the release-based name defined in_helpers.tpl. A release nameddevopsxgives a Pod nameddevopsx. A release namedwebgivesweb-devopsx.nindent 4adds a newline and indents the label block correctly. Wrong indentation is the most common cause of template errors..Values.image.tag | default .Chart.AppVersionuses the tag from values and falls back toappVersioninChart.yamlwhen the tag is empty, which it is by default.
A minimal Chart.yaml. version is the version of the chart itself and must follow SemVer. appVersion is the version of the application inside it.
# devopsx/Chart.yaml
apiVersion: v2
name: devopsx
description: A basic custom chart that runs a single nginx Pod
type: application
version: 0.1.0
appVersion: "1.27"Code language: PHP (php)
The generated values.yaml already contains the image block used above (repository: nginx, pullPolicy: IfNotPresent, tag: ""). You can trim values.yaml down to just that block, but only after replacing NOTES.txt. Otherwise rendering fails because the old notes reference removed keys. A simple replacement:
# devopsx/templates/NOTES.txt
Pod {{ include "devopsx.fullname" . }} was created in namespace {{ .Release.Namespace }}.
Check it with:
kubectl get pod {{ include "devopsx.fullname" . }} -n {{ .Release.Namespace }}
Validate, install and verify
Always render and lint before installing. helm template prints the final YAML without contacting the cluster. --dry-run sends the rendered YAML to the API server for validation but creates nothing.
helm lint ./devopsx
helm template devopsx ./devopsx
helm install devopsx ./devopsx --dry-run
helm install devopsx ./devopsx
helm list
kubectl get pods -l app.kubernetes.io/instance=devopsx
helm get manifest devopsxCode language: JavaScript (javascript)
A successful install prints output similar to this, followed by your notes:
NAME: devopsx
LAST DEPLOYED: <timestamp>
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Pod devopsx was created in namespace default.Code language: HTML, XML (xml)
To override values at install time, use --set or a values file. For example, helm install web ./devopsx --set image.tag=1.26 installs a second release with a different image and a Pod named web-devopsx.
Upgrade, package and clean up
# Apply chart or value changes to an existing release
helm upgrade devopsx ./devopsx --set image.tag=1.26
helm history devopsx
helm rollback devopsx 1
# Package the chart into devopsx-0.1.0.tgz for sharing
helm package ./devopsx
# Remove the release and its Pod
helm uninstall devopsxCode language: PHP (php)
Note: Most fields of a running Pod spec are immutable. An upgrade that only changes the container image works, but changing ports, environment variables or resources fails with Forbidden: pod updates may not change fields.... This is one reason real charts use a Deployment instead of a bare Pod. A bare Pod is fine for learning but isn't recreated if its node fails.
Common errors and fixes
| Error | Cause | Fix |
|---|---|---|
Kubernetes cluster unreachable | Helm can't find a kubeconfig, often because it is running as root after sudo -s | Run Helm as the user who owns ~/.kube/config, or set KUBECONFIG |
cannot re-use a name that is still in use | A release with that name already exists | Use helm upgrade, choose another name, or helm uninstall first |
nil pointer evaluating interface {}.enabled | A template (usually the old NOTES.txt) references a key that was removed from values.yaml | Remove the reference or restore the key |
YAML parse error / error converting YAML to JSON | Wrong indentation in a template | Run helm template and check the indentation around nindent |
Pod stuck in ImagePullBackOff | The image tag doesn't exist | Check appVersion or image.tag, then kubectl describe pod devopsx |
Next steps
Once this works, add a Deployment and Service template, then try lifecycle hooks with Helm Hooks. To manage several releases declaratively, see the Helmfile tutorial.
Frequently asked questions
What is the difference between version and appVersion in Chart.yaml?
version is the SemVer version of the chart itself. Increase it whenever the templates or defaults change. appVersion is informational and describes the application version, and many templates use it as the default image tag.
Do I need sudo to run helm install?
No. Helm uses your kubeconfig and Kubernetes RBAC, not Linux root privileges. Running it as root often fails because root has no kubeconfig.
How do I see the YAML that Helm will apply?
Run helm template <release> <chart-path> to render it locally, or helm get manifest <release> to see what an installed release applied.
Can I install the same chart twice in one namespace?
Yes, as long as each release has a different name and the templates derive resource names from the release, for example with include "devopsx.fullname" .. Hard-coded names cause a conflict on the second install.
Why should I use a Deployment instead of a Pod in a chart?
A Deployment recreates failed Pods, supports rolling updates and lets you change any field of the Pod template on upgrade. A bare Pod has none of these features and is best kept for learning or one-off tasks.
Related tutorials
- Helm Tutorials: What is Helm & How it works?
- Helm Tutorials: Complete tutorials of Helm Hooks
- Helmfile Tutorial: From Beginner to Advanced
- Top 50 Helm interview questions and answers
- More Helm tutorials
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals