问题描述
我希望能够引用values.yaml
中的当前名称空间,以使用它来添加诸如此类的某些值
I would like to be able to reference the current namespace in values.yaml
to use it to suffix some values like this
# in values.yaml
someParam: someval-{{ .Release.Namespace }}
用这种方式定义它比进入我的所有模板并添加{{ .Release.Namespace }}
更好.如果我可以在values.yaml
中做到这一点,那就更清楚了,只需要在一个地方定义即可.
It much nicer to define it this way instead of going into all my templates and adding {{ .Release.Namespace }}
. If I can do it in values.yaml
it's much clearer and only needs to be defined in one place.
推荐答案
如果您知道someParam
可能包含模板构造,Helm会包含 tpl
函数对其进行解释.
If you know that someParam
might contain templating constructs, Helm includes a tpl
function that interprets it.
- name: SOME_VARIABLE
value: {{ .Values.someParam | tpl }}
如果图表允许这样做,通常会对其进行记录.作为一个具体示例, helm/charts PostgreSQL图表记录了其configurationConfigMap
设置为
If a chart allows this it generally documents it. As a specific example, the helm/charts PostgreSQL chart documents that its configurationConfigMap
setting is
因此,对于该特定值,您可以将模板宏放在values.yaml
文件中.
So for that specific value, you can put a template macro in the values.yaml
file.
这篇关于我如何在values.yaml中引用命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!