Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm Interpolation

I am setting the following environment variable in Helm Deployment like so.

name: SERVER_ENDPOINT
value: {{ .Values.server.dev_proxy_endpoint }}

But would like to interpolate the environment part (dev) of the value variable, like so

name: SERVER_ENDPOINT
value: {{ .Values.server. {{ .Values.environment | lower }} _proxy_endpoint }}

Is this possible?

Reply to first comment

I tried that out by creating a new definition at the top of the file like so:

{{- $value_path_to_endpoint := print ".Values.server." .Values.environment  "_proxy_endpoint" -}}

But that then presents a literal value, rather than the context pointer to the values file.

name: SERVER_ENDPOINT
value: {{ $value_path_to_endpoint}}

In other words, $value_path_to_endpoint returns:

".Values.server.dev_proxy_endpoint"

Rather than

.Values.server.dev_proxy_endpoint
like image 255
Theo Sweeny Avatar asked Apr 09 '26 08:04

Theo Sweeny


1 Answers

You can use index function from Go text/template and Helm's printf function

env:
- name: SERVER_ENDPOINT
  value: {{ (index .Values.server (printf "%s_proxy_endpoint" ( .Values.environment | lower ))) }}
like image 200
edbighead Avatar answered Apr 12 '26 03:04

edbighead



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!