例如,我有
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:
我想做这样的事情
env:
name: WORDPRESS_DB_HOST
value: {{ .Values.database.name | lower }}
所有这些都是来自同一values.yaml
这在Helm中可能吗?
答案 0 :(得分:0)
是的,您可以实现此using the 'tpl' function
tpl函数允许开发人员将字符串作为模板内的模板求值。将模板字符串作为值传递到图表或呈现外部配置文件时,这很有用。语法:{{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 . }}
输出:
> helm template .
# Source: mychart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: release-name-configmap
data:
some: X-A2D9F4