Video Thumbnail for Lesson
5.3: Authoring Helm Charts

Authoring Helm Charts

Helm provides a helm create command that scaffolds the boilerplate for a new chart. The repository for this course contains two examples:

  • helm-create-unmodified – the raw output from helm create so you can explore all of the default files generated by Helm.
  • minimal – a stripped-down chart used in the video to demonstrate common templating features.

Chart Metadata

Every chart has a Chart.yaml defining its metadata. Here is the file from the minimal example:

apiVersion: v2
name: minimal
description: A tiny helm chart for educational purposes
type: application
version: 0.1.0
appVersion: 1.26.0

type can be application or library. Application charts install resources into the cluster while library charts expose reusable templates for other charts.

Default Values

The values.yaml file provides default configuration. For the minimal chart:

environment: production

configData:
  - key: conditionalKey
    value: "this will be included"
    enabled: true

A second values file (values-alt.yaml) shows how different environments can override these defaults.

Helpers and Templates

Templates live in the templates/ directory. The _helpers.tpl file defines reusable variables such as envShort:

{{- define "envShort" -}}
{{- if eq .Values.environment "production" -}}
prod
{{- else -}}
non-prod
{{- end -}}
{{- end -}}

The chart renders a ConfigMap that uses this helper and loops over configData items:

apiVersion: v1
kind: ConfigMap
metadata:
  name: helm-{{ .Release.Name }}-configmap
data:
  appVersion: {{ .Chart.AppVersion }}
  environment: {{ .Values.environment | quote }}
  envShort: {{ template "envShort" . }}
  {{- range .Values.configData }}
  {{- if .enabled }}
  {{ .key }}: {{ .value | quote }}
  {{- end }}
  {{- end }}

A simple NOTES.txt file prints information after installation:

Hi \U1F44B -- you just deployed {{ template "envShort" . }}

Installing the Chart

Use helm upgrade --install to deploy the chart from a local path:

helm upgrade --install demo ./minimal -n 05-helm --create-namespace

Passing an alternate values file modifies the rendered output:

helm upgrade --install demo ./minimal -f values-alt.yaml -n 05-helm

Inspect the resulting config map with:

kubectl get configmap -n 05-helm -o yaml

When finished, delete the namespace to clean up:

kubectl delete namespace 05-helm

Helm Hooks

Helm also supports hooks for running resources before or after installs and upgrades. They are useful for tasks like database migrations or cleanup jobs and are covered briefly in the video.

You can find these example charts in the course repository if you want to explore further.