Use of {{ block }} inside {{ define }} in helm templates

3/12/2019

Can someone explain (or point to good explanation) on the use of {{ block }} inside {{ define }} in helm templates? I’m going nuts trying to find good example or clear explanation - i’m not seeing the difference using that vs just {{ define }} alone

-- meeech
kubernetes-helm

1 Answer

3/13/2019

I've never seen {{ block }} in a Helm template.

The Go text/template documentation says of block:

The typical use is to define a set of root templates that are then customized by redefining the block templates within.

That would make more sense if you had something like a base HTML page layout you were reusing in several places and could customize it by redefining the content. Helm templates tend to just not have that setup. Even though the Kubernetes YAML files are pretty repetitive, things like the number and kind of objects are highly variable even across similar-looking charts.

-- David Maze
Source: StackOverflow