How can you call a helm 'helper' template from a subchart with the correct context?

后端 未结 3 1389
情歌与酒
情歌与酒 2021-02-02 15:16

Helm charts define helper templates in _helpers.tpl which are used to create normalized names for the services. The standard form of the template for a service (DNS

3条回答
  •  春和景丽
    2021-02-02 15:39

    I wrote an issue helm/helm#4535 that summarizes the status-quo and proposes an enhancement to Helm which will solve this case.

    For anyone looking for an interim solution, I wrote (see my follow-up comment for details) a meta-template that calls any given template in an "ersatz" subchart's scope. It works by synthesizing a dot-object. It is not perfect (not all fields are synthesized), but it will do:

    {{- define "call-nested" }}
    {{- $dot := index . 0 }}
    {{- $subchart := index . 1 }}
    {{- $template := index . 2 }}
    {{- include $template (dict "Chart" (dict "Name" $subchart) "Values" (index $dot.Values $subchart) "Release" $dot.Release "Capabilities" $dot.Capabilities) }}
    {{- end }}
    

    Usage (to call a redis.fullname template of a redis subchart):

    {{ include "call-nested" (list . "redis" "redis.fullname") }}
    

提交回复
热议问题