helm values.yaml - use value from another node

8/7/2019

so for example i have

database:
  name: x-a2d9f4
  replicaCount: 1
  repository: mysql
  tag: 5.7
  pullPolicy: IfNotPresent
  tier: database

app:
  name: x-576a77
  replicaCount: 1
  repository: wordpress
  tag: 5.2-php7.3
  pullPolicy: IfNotPresent
  tier: frontend

global:
  namespace: x-c0ecdb9f

env:
  name: WORDPRESS_DB_HOST
  value:

and I want to do something like this

env:
  name: WORDPRESS_DB_HOST
  value: {{ .Values.database.name | lower }}

All these are examples from the same values.yaml

is this possible in Helm?

-- Eli
kubernetes-helm

1 Answer

8/7/2019

Yes, you can achieve this using the 'tpl' function

The tpl function allows developers to evaluate strings as templates inside a template. This is useful to pass a template string as a value to a chart or render external configuration files. Syntax: {{ tpl TEMPLATE_STRING VALUES }}

values.yaml

database:
  name: x-a2d9f4

env:
  name: WORDPRESS_DB_HOST
  value: "{{ .Values.database.name | upper }}"

configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap
data:
  some: {{ tpl .Values.env.value . }}

output:

> helm template .

# Source: mychart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: release-name-configmap
data:
  some: X-A2D9F4
-- edbighead
Source: StackOverflow