docs / articles / Helm Template Ranges Over List

Helm Template Ranges Over List

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

In the realm of infrastructure as code (IaC), the GO language, with its powerful text templating engine, offers the Helm package for package managers. Helm templates, like many other templating engines, provide dynamic content that evolves based on input data. One such input for Helm templates is a list, where we often need to apply the same structure to multiple items. Here, we explore using the range function in Helm templates to traverse a list.

Helmet Template – Large
Helmet Template – Large

Helm templates use a Go template syntax, which empowers users to express complex logic with scoping, functions, and more. When dealing with a list, the range function is a workhorse for traversing elements, applying structure, and rendering values to the final configuration.

a blueprint drawing of a motorcycle helmet with the measurements and details for it's size
a blueprint drawing of a motorcycle helmet with the measurements and details for it's size

Understanding the Helm Template Range Function

At its core, the range function in Helm templates follows the Go template syntax for looping over a series or list. It takes two arguments: the first argument is the name of the variable to be used inside the loop, and the second is the value that needs to be iterated over.

the helmet and visor are shown in three different positions
the helmet and visor are shown in three different positions

Here's a simple example: {{range .Items}} will loop over .Items in the current context (usually a list of Kubernetes objects). Inside the range block, you can use the (.Name, .Type, .ID, etc.) as variables, where applicable.

Basic Helm Template Range Syntax

Headgear Alignment Chart
Headgear Alignment Chart

The basic syntax for range in Helm looks like this:

{{range := .-}} // content to be repeated for each element in the list {{end}}

Here, is assigned the value of each item in during each iteration of the loop.

Range with a Key and Value

three views of the front, back and side of a motorcycle helmet on a white background
three views of the front, back and side of a motorcycle helmet on a white background

Sometimes, a list might be an association list where each element has a key-value pair. In these situations, you can specify two variables in the range function. This approach is helpful when each list item must be accessed by key.

{{range $key, $value := .-}} // content to iterate over each key-value pair {{end}}

In this case, the key is used as the loop index, while the value presents the current item.

The Power of Range in Helm Templates

an image of a helmet with measurements and instructions for the parts to be used in this project
an image of a helmet with measurements and instructions for the parts to be used in this project

The range function unlocks the ability to apply uniform structures to multiple elements, facilitate repetitive tasks, and generate configurations en masse. Its simplicity belies its power, as it forms a core capability for dynamic templating in Helm.

The range function is a key component for rendering lists, repeating blocks, and conditioning the content based on the current list item. Understanding how to use range in Helm templates is essential for harnessing the full power of Helm. Helios the titan of Greek mythology may have been the herald of the gods, but in the realm of Helm, the function-range serves as the herald of dynamic contents.

FAST XP SETUP LNR07
FAST XP SETUP LNR07
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
Drawing of a knight's helmet
Drawing of a knight's helmet
the color picker is showing different colors and font options for each letter on the screen
the color picker is showing different colors and font options for each letter on the screen
the table shows different colors and numbers for each type of item, as well as their corresponding
the table shows different colors and numbers for each type of item, as well as their corresponding
Hats
Hats
helm template range over list
helm template range over list