是否可以将模板blob文本包含到values.yaml中?



为了向后兼容(以及减少更新src代码的负担),如下:

有一个用户输入:

values.yaml美元

output:
endpoint: MYENDPOINT
specialFile: 
config1: |-
Some very nicely formated text.
Wow, such sample. 
Much text.
[...]
config2: |-
# this is also text but i need to remove |- for interpretation
{{- $.Files.Get "configs/include.conf" | nindent 4 }}

我想用一团文本替换的

配置美元/include.conf

<match **>
@type http
endpoint_url    {{ .Values.output.endpoint }}
serializer      json
</match>

以便输出替换文本上的var,文本替换values.yaml上的value。这可能吗?我知道这几乎是不可能的。我已经看到有人在替换价值。Yaml与自己(没有尝试我自己),但这是可能的吗?

或者我可以覆盖。values . specialfile。configs2值,而不直接写入.Values文件并以某种方式覆盖变量,可能使用模板?

这可以通过使用tpl:

将包含的文件作为嵌套模板处理来实现:
{{ $endpoint := "MYENDPOINT" }}
output:
endpoint: {{ $endpoint }}
specialFile: 
config1: |-
Some very nicely formated text.
Wow, such sample. 
Much text.
[...]
config2: |-
# this is also text but i need to remove |- for interpretation
{{- tpl ($.Files.Get "configs/include.conf") $endpoint | nindent 4 }}

为了避免重复,我将端点放在一个变量中,并将其传递给加载的模板。因此,它将作为{{.}}在这里可用:

<match **>
@type http
endpoint_url    {{ . }}
serializer      json
</match>

最新更新