【问题标题】:Nested values are not able to be evaluated无法评估嵌套值
【发布时间】: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


【解决方案1】:

根据上面的评论,我看到你能够克服这个问题,我想添加问题的答案以供其他人查找。

默认的values.yaml 文件是小写的(尽管我们在模板中使用了.Values)。

你可以做的是:

  • 使文件名以小写字母开头或
  • 使用-f 选项显式传递值文件

【讨论】:

  • 知道什么是文件名会阻止仅访问嵌套值是有用的。如果它无法读取\查找文件但能够读取某些值但不能读取其他值,我可以理解它会留下更多问题。
猜你喜欢
  • 2019-07-22
  • 2022-01-10
  • 1970-01-01
  • 1970-01-01
  • 2013-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-26
相关资源
最近更新 更多