我使用helmfile来安装我的Helm图表和其他依赖关系图。我希望在值文件中使用模板化的值。
从这解决的问题来看,它看起来像是支持值文件中的模板。但是,我使用以下文件进行了测试:helmfile.yaml
environments:
default:
values:
- my:
port: 8080
---
repositories:
- name: incubator
url: https://kubernetes-charts-incubator.storage.googleapis.com
releases:
- name: haproxy-ingress
namespace: haproxy-ingress
chart: incubator/haproxy-ingress
version: 0.0.27
values:
- values.yamlvalues.yaml
controller:
tcp:
1936: "my_namespace/my-service:{{ .Values.my.port }}"如果我运行helmfile template,我会
COMBINED OUTPUT:
Error: template: haproxy-ingress/templates/tcp-configmap.yaml:16:31: executing "haproxy-ingress/templates/tcp-configmap.yaml" at <tpl $value $>: error calling tpl: error during tpl function execution for "my_namespace/my-service:{{ .Values.my.port }}": template: haproxy-ingress/templates/tcp-configmap.yaml:1:34: executing "haproxy-ingress/templates/tcp-configmap.yaml" at <.Values.my.port>: nil pointer evaluating interface {}.port
Use --debug flag to render out invalid YAML如果我内联这些值,它就能工作。
environments:
default:
values:
- my:
port: 8080
---
repositories:
- name: incubator
url: https://kubernetes-charts-incubator.storage.googleapis.com
releases:
- name: haproxy-ingress
namespace: haproxy-ingress
chart: incubator/haproxy-ingress
version: 0.0.27
values:
- controller:
tcp:
1936: "my_namespace/my-service:{{ .Values.my.port }}"发布于 2020-10-08 01:58:57
我知道答案了。从地狱档案的文件来看,
您可以在helmfile.yaml和values.yaml.gotmpl (模板头盔值文件)中使用go的文本/模板表达式。values.yaml引用将逐字使用。换句话说:对于以.gotmpl结尾的值文件,将为普通值文件(以.yaml结尾)呈现模板表达式,内容将按原样使用。
因此,在这种情况下,应该将values.yaml重命名为values.yaml.gotmpl,以便helmfile将文件解释为go模板。
https://stackoverflow.com/questions/64185839
复制相似问题