docs / articles / Helm Lookup Function Examples

Helm Lookup Function Examples

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

The Helm lookup function is an essential tool for Kubernetes cluster administration, allowing you to retrieve information about Kubernetes resources. Understanding how to use this function effectively is crucial for managing and monitoring your cluster efficiently. In this article, we'll delve into the Helm lookup function, its syntax, and provide practical examples to help you master its usage.

VLOOKUP vs HLOOKUP vs XLOOKUP (Part 2) | Key Differences Explained in Excel
VLOOKUP vs HLOOKUP vs XLOOKUP (Part 2) | Key Differences Explained in Excel

Before we dive into the examples, let's briefly understand the Helm lookup function. The lookup function is part of the official Helm documentation and is used to retrieve values from a specific chart's values.yaml file. It's particularly useful when you want to use dynamic values in your charts.

Top 9 Excel Lookup Functions Every Excel User Must Know
Top 9 Excel Lookup Functions Every Excel User Must Know

Basic Syntax and Examples

The basic syntax for the Helm lookup function is {{ lookup "path/to/file.yaml" "key" }}. Here, "path/to/file.yaml" is the path to the YAML file where the value is stored, and "key" is the key associated with the value you want to retrieve.

Mastering Excel Lookup Functions: A Quick Guide
Mastering Excel Lookup Functions: A Quick Guide

Let's consider a simple example. Suppose you have the following values.yaml file:

``` message: Hello, World! greeting: {{ lookup "values.yaml" "message" }} ```

When you render this, Helm will replace {{ lookup "values.yaml" "message" }} with Hello, World!

a poster with the words lookup functions in green and white, along with an image of
a poster with the words lookup functions in green and white, along with an image of

Lookup within a Chart

You can also perform lookups within the current chart. To do this, use the .xxx syntax. For example, suppose your values.yaml file has:

``` service: type: LoadBalancer ```

And you want to use this value in your templates. You can do so like this:

Excel LOOKUP Practice Sheet | VLOOKUP, XLOOKUP & INDEX-MATCH
Excel LOOKUP Practice Sheet | VLOOKUP, XLOOKUP & INDEX-MATCH

``` apiVersion: v1 kind: Service metadata: name: {{ include "myChart.fullname" . }}-service spec: type: {{ .Values.service.type | default "ClusterIP" | quote }} ```

In this example, {{ .Values.service.type }} will be replaced with LoadBalancer if it's set in your values.yaml file. If not, it defaults to "ClusterIP".

Lookup within a values.yaml File from Another Chart

You can also perform lookups in values.yaml files from other charts. Suppose you have a dependent chart with a values.yaml file like this:

the evolution of excel lookup function info sheet with text and numbers for each column
the evolution of excel lookup function info sheet with text and numbers for each column

``` harbor: secretKey: myKey ```

You can perform a lookup in your parent chart like this:

``` {{ lookup "myDepChart/values.yaml" "harbor.secretKey" }} ```

Lookup Best Practices

Evolution of Lookup functions in Excel from Lookup to XLOOKUP
Evolution of Lookup functions in Excel from Lookup to XLOOKUP
HLOOKUP Formula in Excel: How to Use and Master It
HLOOKUP Formula in Excel: How to Use and Master It
LOOKUP Function in Excel Explained | Beginner Friendly Excel Formula (part 19)
LOOKUP Function in Excel Explained | Beginner Friendly Excel Formula (part 19)
an excel lookup function is shown in the form of a line with numbers and symbols
an excel lookup function is shown in the form of a line with numbers and symbols
an image of a cell phone screen with the text'hookup'on it
an image of a cell phone screen with the text'hookup'on it
a poster with instructions on how to use an excel lookup function
a poster with instructions on how to use an excel lookup function
INDEX & MATCH Functions Combo in Excel (10 Easy Examples)
INDEX & MATCH Functions Combo in Excel (10 Easy Examples)

While the lookup function is powerful, it's essential to use it judiciously. Overusing lookups can make your charts more complex and harder to maintain. Here are a few best practices:

1. **Avoid Circular Dependencies**: Be cautious about creating circular dependencies where chart A depends on the value of chart B, which in turn depends on a value from chart A. This can make your charts harder to manage and may even cause them to fail.

2. **Use Defaults**: Always provide default values for your lookups. If the key you're looking up doesn't exist, Helm will throw an error. Defaulting to a known value can prevent this.

3. **Keep Related Values Together**: If you're using lookups to set related values, consider using a dictionary or object to keep them together. This makes your charts easier to understand and maintain.

Finally, always remember that the Helm lookup function is just a tool. It's up to you to use it in a way that makes your charts more manageable and easier to understand. By following best practices and understanding the limitations of the lookup function, you can unlock its full potential.