如何在掌舵图中使用模板内的模板?

How to use templates inside templates in helm chart?

我想在带有“.”的模板中使用模板。我的掌舵图中的运算符。

假设这是我的 values.yaml

component: my-component
my-component-arguments:
  heap_opts: "heap-opts" 

现在我想获取“heap_opts”,但组件名称是动态的。 我怎样才能使用模板做这样的事情?

{{ .Values."{{.Values.component}}-arguments".heap_opts }}

您可以使用 text/template

中的 get spring function combined with index and printf 来完成此操作
{{ get (index .Values (printf "%s-arguments" .Values.component)) "heap_opts" }}