Skip to content

Helm loop through key:value pairs

What

In helm, sometimes you want to creat resources off a key value list.

A good example would be a service load balancer in GKE, it can have a firewall automatically created

See here to read more about that

How

In your values.yaml file

config:
  list:
    bradley: "is cool"

Then your resource would use:

{{- range $k,$v := .Values.config.list}}
        - secretKey: {{$v}}
          remoteRef:
            key: {{$k}}
        {{- end }}

Overview

To go through the list, you use {{$k}} for the key, and {{$v}} for the value


Want to make this site better? Open a PR or help fund hosting costs