Creating a Helm Chart

Where we are in our stages

A couple of rules first

  • chart names should be lower case letters, numbers and dashes. No underscores, dots, or uppercase letters. Stay away from special characters too, like /\!@#$%^ and others.
  • Chart names must match the name of the parent directory. If you have a chart named myapp, it should be in a directory called myapp. This will get made automatically as you will see below.
  • Helm uses SemVer2 verisoning.
  • have Helm installed on your machine

Hello-World, again.

Here’s our repo. It has all the completed files in it.

We are using Helm v.3.1.2.

Initialize your directory

Navigate to the root of your source code and run this command helm create <chart-name> . This will create a new sub-directory with the name of your chart. In our case it’s hello-world.

newly created directory structure

Delete the contents of the following files, but don’t delete the files themselves.

hello-world/templates/deployment.yaml
hello-world/templates/ingress.yaml
hello-world/templates/NOTES.txt
hello-world/templates/service.yaml
hello-world/templates/serviceaccount.yaml
hello-world/templates/test/test-connection.yaml
empty files

Chart.yaml

/hello-world/Chart.yaml

Chart.yaml

values.yaml

/hello-world/values.yaml

current configmap.yaml
added key:value pairs in values.yaml
values.yaml with a camelCase key

Create a configmap template if you are using one

Helm has supplied a bunch of files, but there are a few that don’t come prepackaged. One of those is a configmap.

our configmap.yaml again
using the new value camelCase value

Let’s test our changes in the command line.

helm install --dry-run — debug hello-world .\hello-world -f hello-world\values.yaml

  1. We attempted to install the chart, but used the --dry-run parameter so it’s not actually going to install anything.
  2. All we have is a configmap so it would’ve installed a configmap without --dry-run
  3. hello-world is the name of your chart
  4. .hello-world\ is the path to your chart
  5. -f hello-world\values.yaml is telling helm you want to use this values file.
  • values.yaml is where all your data lives
  • the curly braces basically says replace this with the values defined. Here it’s fromValues(from the values.yaml file).airwaveHWPort(the key inside of the values.yaml file).

More Templates

Just like how we copied our existing configmap.yaml to /hello-world/templates/configmap.yaml we need to do the same for some of the other files we need.

deployment.yaml

/hello-world/templates/deployment.yaml

before
templatized

service.yaml

/hello-world/templates/services.yaml

before
templatized

Test

helm install --dry-run — debug hello-world .\hello-world -f hello-world\values.yaml

confimap, service, and deployment files have interpolated the values.

Deploy it

helm install --debug hello-world .\hello-world -f hello-world\values.yaml

lots of output
  • deployment
  • service
  • configmap
proof the 3 resources were created

Package it

helm package hello-world\

Recap

Today, we learned:

  • how to create a Helm chart
  • how Helm values work
  • how to turn your existing Kubernetes manifests into Helm templates
  • how to deploy your chart
  • how to package your chart

To delete

helm delete hello-world

Next Steps

We would need to send this chart to some kind of Helm repository so that we can reach it from any server that has access. With all that we covered, I will leave you all with this.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store