Chapter 5. Developing Templates

Templates are at the heart of Helm charts, and they make up a majority of the files and content of a chart. These are the files that live within the templates directory. Helm will render the templates and send them to Kubernetes when you run commands like helm install and helm upgrade. If you use the helm template command, the templates are rendered and displayed as output (i.e., sent to standard out).

The template engine enables a wide range of ways to build templates. In simple situations, you can substitute values in Kubernetes manifest YAML files with values passed in by the user or from the values.yaml file. In more complex situations, you can build logic into templates that simplify what chart consumers need to input. Or you can build in features that can configure applications themselves.

In this chapter you will learn how to develop templates and understand how the template syntax works. We’ll also cover a number of cool features that Helm has added to the templates that enable you to work with YAML and interact with Kubernetes. Along the way we will look at some patterns you can apply to your own templates.

The Template Syntax

Helm uses the Go text template engine provided as part of the Go standard library. The syntax is used in kubectl (the command-line application for Kubernetes) templates, Hugo (the static site generator), and numerous other applications built in Go. The template engine, as it is used in Helm, is designed to work with ...

Get Learning Helm now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.