Helm CLI comes with a template sub-command that outputs the YAML it generates without installing the Chart. This is very useful for debugging templates and writing Post Renderer scripts.
Here is a basic example to illustrate its usage:
helm template --generate-name /path/to/your/chart/directory --post-renderer /path/to/your/post-render.sh
The output of helm template
command
Since looking at the generated YAML of a large Chart can be overwhelming, we can pipe the output of helm template
to a pager like less
and search for what we're interested in:
The paged output of helm template
command with less
This approach works but it has a major drawback. With every change, we have to exit the pager, run the command again, and go back to where we were before. That can be very inconvenient and time-consuming.
Using something like watch
is not an option either as the output of watch
is not scrollable and it's not possible to pipe it to a pager.
The output of the watch
command is not scrollable
While it's possible to work around this issue by using a terminal multiplexer (such as screen
or tmux
) instead of a pager or saving the output of the watched command to a file and auto reloading the file in a text editor, there's a much more elegant solution: Viddy!
Viddy, in a nutshell is less
combined with watch
. It has many fancy features and offers lots of customization options, but for our use-case we can simply run the following command to watch the output of helm template
in a pager and update it every second:
viddy -dtn 1 "helm template --generate-name /path/to/your/chart/directory --values /path/to/your/values.yaml --post-renderer /path/to/your/post-render.sh"
Watching the output of helm template
with Viddy
While it is running, changing the contents of values.yaml
or the post-renderer.sh
script will update the output and highlights the changes. It's such a game-changer for debugging and authoring Helm Charts and Post Rendering Hooks! 😎