docs / articles / Helm Template Example: Create & Use in Minutes

Helm Template Example: Create & Use in Minutes

Noah Aug 16, 2026 2026-08-16 04:58:21

Helm is a powerful templating engine for Kubernetes that makes it easy to define, package, and deploy applications as Helm charts. Understanding how to write a Helm template example is crucial for leveraging Helm's capabilities to its fullest. Let's delve into the world of Helm templates, their purpose, and explore an example to illustrate their usage.

Elegant Helm Template For Rails Project
Elegant Helm Template For Rails Project

At its core, Helm templates are Go templates that are used to generate Kubernetes resources. They allow you to define dynamic content, enabling you to create reusable and customizable charts. Helm templates make use of Go's templating syntax, extended with some Helm-specific functions.

the heinet base build template is shown in three different sizes, including one for each
the heinet base build template is shown in three different sizes, including one for each

Understanding Helm Templates

Helm templates play a pivotal role in chart creation, allowing you to generate Kubernetes manifests with ease. They enable you to define dynamic values like version numbers, image tags, or custom configurations, ensuring that your charts remain flexible and adaptable to various environments.

Templates — SKS PROPS
Templates — SKS PROPS

Helm templates use the Go templating language, which inherits from text/template and utilizes double-brace syntax for instruction execution. Understanding this syntax is essential for writing effective Helm templates.

Double-Brace Syntax

Viking Helmet Template – Medium
Viking Helmet Template – Medium

The double-brace syntax is the core of Helm templating. It's used to execute instructions and perform actions like looping, conditional statements, and function calls. The template engine first processes the text within the double-brace brackets, and then replaces them with the evaluated results.

For example, {{ .Values.example }} will be replaced with the value of the 'example' key in the 'values' section of the chart. If the key doesn't exist, it will be replaced with an empty string.

Go Template Functions

Confira esta imagem
Confira esta imagem

Helm supports all the built-in functions from the Go template package. Some of the most frequently used functions include 'len', 'range', and 'println'. These functions allow you to perform operations and manipulate data directly within your templates.

For instance, the 'range' function enables you to loop through a data structure, while 'len' gets the length of an array or string. The 'println' function is used for print debugging or logging purposes.

Exploring a Helm Template Example

EVA Foam Agamemnon Helmet Template Pattern Inspired by The Odyssey
EVA Foam Agamemnon Helmet Template Pattern Inspired by The Odyssey

A comprehensive understanding of Helm templates can be gained by examining a practical example. Let's consider a simple Helm chart that deploys a basic Nginx server.

In this chart, the templates/Ingress.yaml file might look something like this:

Greek Helmet Template – Large
Greek Helmet Template – Large
DIY Valkyrie helmet template
DIY Valkyrie helmet template
Printable Roman Helmets
Printable Roman Helmets
헬멧모형
헬멧모형
Firefighter Helmet Shield Silhouette Images – Browse 920 Stock Photos, Vectors, and Video
Firefighter Helmet Shield Silhouette Images – Browse 920 Stock Photos, Vectors, and Video
Helm of Solaire (Dark Souls) digital template for prop making
Helm of Solaire (Dark Souls) digital template for prop making
Drawing of a knight's helmet
Drawing of a knight's helmet
Helmet Template – Large
Helmet Template – Large
Arai CK6 all views - (VECTOR DESIGN TEMPLATE)
Arai CK6 all views - (VECTOR DESIGN TEMPLATE)

```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ include "nginx.fullname" . }} labels: {{- include "nginx.labels" . | nindent 4 }} spec: rules: - host: {{ .Values.ingress.host }} http: paths: - pathType: Prefix path: "/" backend: service: name: {{ include "nginx.serviceName" . }} port: number: {{ .Values.service.port }} ```

The above example showcases several key aspects of Helm templating. It uses the 'include' function to call other templates, dynamic values retrieved from '.Values', and the 'nindent' function for proper indentation.

Using the 'include' Function

The 'include' function is a Helm-specific function that allows you to insert the contents of another template into the current one. In this example, 'nginx.fullname' and 'nginx.labels' are defined in separate templates and then included here.

This promotes code reusability and keeps your templates clean and organized by separating different aspects of your chart into distinct files.

Retrieving Dynamic Values

The '.Values' dictionary contains the customizable values defined in your 'values.yaml' file. Here, {{ .Values.ingress.host }} and {{ .Values.service.port }} will be replaced with the values set by the user.

This dynamic nature makes your charts flexible and adjustable, enabling users to customize various aspects of the deployment.