【发布时间】:2021-12-04 01:36:43
【问题描述】:
我正在使用 helm v 3.7.0,并且我有一个父图表,其中包含一些子图表作为依赖项。 其中一个子图表具有如下定义的虚拟服务。
子图表 Values.yaml:
ingress:
enabled: true
host: "hostname.local"
annotations: {}
tls: []
子图 virtual.service.yaml:
{{- if .Values.ingress.enabled -}}
apiVersion: types.kubefed.io/v1beta1
kind: FederatedVirtualService
metadata:
name: {{ template "product.fullname" . }}-web-vservice
spec:
placement:
clusterSelector: {}
template:
spec:
gateways:
- {{ template "product.fullname" . }}-web-gateway
hosts:
- {{ .Values.ingress.host }}
http:
# Website
- match:
- uri:
prefix: /
route:
- destination:
host: {{ template "product.fullname" . }}-web
port:
number: 80
{{- end }}
当我跑步时:
helm template . --debug
它出错了:
Error: template: virtual.service.yaml:1:14: executing "virtual.service.yaml" at <.Values.ingress.enabled>: nil pointer evaluating interface {}.enabled
如果我将启用的布尔值移到入口之外并更新它的 if 语句。 IE。 新价值观:
ingressEnabled: true
ingress:
host: "hostname.local"
annotations: {}
tls: []
新的虚拟服务:
{{- if .Values.ingressEnabled -}}
apiVersion: types.kubefed.io/v1beta1
kind: FederatedVirtualService
问题是这种情况到处都在发生,有很多不同的值,但仅限于它们嵌套的地方,我不能让所有值都变平。
我在其他项目中以完全相同的方式指定虚拟服务,并且它们运行良好。我不认为问题在于我如何定义它(除非有人可以纠正我?)所以我认为其他东西阻止了 helm 能够读取嵌套值,但我不知道在哪里可以调查这个奇怪的行为。
什么会导致 helm 无法读取嵌套值?
【问题讨论】:
-
不确定这是否重要,但我认为默认 values.yaml 是小写的。您是否尝试过使文件名以小写字母开头或使用
-f显式传递值文件? -
我知道这会很愚蠢,就是这样。谢谢!我从来没有想过它可能是因为它可以读取一些值。
标签: kubernetes-helm