Create a helm chart template

helm template chart

2 min read | by Jordi Prats

To get started creating a helm chart on our own there are some common structure that we can reuse from chart to chart: We can let helm create the basic structure for us

To do so we just need to use helm create specifying the name of the chart we want to use:

$ helm create helmproject
Creating helmproject

It will create a structure as follows:

$ find helmproject
helmproject
helmproject/Chart.yaml
helmproject/values.yaml
helmproject/templates
helmproject/templates/hpa.yaml
helmproject/templates/_helpers.tpl
helmproject/templates/ingress.yaml
helmproject/templates/NOTES.txt
helmproject/templates/service.yaml
helmproject/templates/serviceaccount.yaml
helmproject/templates/tests
helmproject/templates/tests/test-connection.yaml
helmproject/templates/deployment.yaml
helmproject/charts
helmproject/.helmignore

It will use the project name we are using for some of the variables it creates such as labels.

$ cat helmproject/templates/_helpers.tpl 
{{/*
Expand the name of the chart.
*/}}
{{- define "helmproject.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

(...)

It's a good way of getting started creating a helm chart even though we most likely end up deleting some of the templates or just rewriting most of the template. But that's what templates are for, right?


Posted on 22/04/2021

Categories