MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Helm Tutorials: How to create Basic Custom Charts

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 with kubectl get nodes.
  • Helm 3 or later installed. Check with helm version. Helm 3 needs no Tiller and uses the same kubeconfig as kubectl.
  • Optional: the tree utility for viewing the chart layout (sudo apt-get install -y tree on 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

  1. Scaffold the chart: helm create devopsx.
  2. 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. Run ls afterwards. If your Helm version generated other resource templates, such as an HTTPRoute, delete those too.
  3. Create templates/pod.yaml with the template shown in the next section.
  4. Replace templates/NOTES.txt with a short message (example below).
  5. Edit Chart.yaml to set the description, chart version and appVersion.
  6. Go back to the parent directory and validate: helm lint ./devopsx and helm template devopsx ./devopsx.
  7. 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 named devopsx gives a Pod named devopsx. A release named web gives web-devopsx.
  • nindent 4 adds a newline and indents the label block correctly. Wrong indentation is the most common cause of template errors.
  • .Values.image.tag | default .Chart.AppVersion uses the tag from values and falls back to appVersion in Chart.yaml when 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

ErrorCauseFix
Kubernetes cluster unreachableHelm can't find a kubeconfig, often because it is running as root after sudo -sRun Helm as the user who owns ~/.kube/config, or set KUBECONFIG
cannot re-use a name that is still in useA release with that name already existsUse helm upgrade, choose another name, or helm uninstall first
nil pointer evaluating interface {}.enabledA template (usually the old NOTES.txt) references a key that was removed from values.yamlRemove the reference or restore the key
YAML parse error / error converting YAML to JSONWrong indentation in a templateRun helm template and check the indentation around nindent
Pod stuck in ImagePullBackOffThe image tag doesn't existCheck 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

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
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.

Related Posts

Helm Tutorials: helm show commands

helm show prints a chart's information without installing it. That covers the Chart.yaml metadata, the default values.yaml, the README and any CRDs. This page explains each subcommand…

Read More

Openshif: Create a busybox pod

This page shows how to start a temporary BusyBox pod in OpenShift with oc run. The pod passes the restricted security policies, so you can test DNS,…

Read More

OpenShift Lab 10: View Pod, Workload, and Namespace Performance Metrics Using the OpenShift Web Console

This lab uses the OpenShift web console to view CPU, memory, network and pod metrics for one namespace and its workloads. It then checks the same numbers…

Read More

Kubernetes: Pull an Image from a Private Registry using Yaml and Helm File

Kubernetes pulls images from a private registry using a kubernetes.io/dockerconfigjson Secret. A Pod references that Secret through imagePullSecrets, either directly or through its ServiceAccount. This page shows…

Read More

Deploying Nexus Certificate Manager (CM) and Protocol Gateway (PGWY) on Kubernetes

Step-by-step tutorial, written from an actual deployment of Certificate Manager 8.15.1-1 (CF server image 8.15.1-1, PGW image 8.15.1-1) on a 2-node kubeadm cluster. Status of this document (2026-11-12) Steps 1-8 were executed…

Read More

Kubernetes ReplicaSet Explained: API Resource, YAML Example, and Use Cases

Rajesh Kumar 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…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x