Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fardjad/7532a2b275e255ae92494435f2220c73 to your computer and use it in GitHub Desktop.
Save fardjad/7532a2b275e255ae92494435f2220c73 to your computer and use it in GitHub Desktop.
[Debugging and Authoring Helm Charts and Post Rendering Hooks with Viddy] #helm #viddy #watch #kubernetes #yaml #less #pager

Debugging and Authoring Helm Charts and Post Rendering Hooks with Viddy

Fardjad Davari
Published on GitHub Gist

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

Helm Template

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:

Less

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.

Watch Command

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"

Viddy

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! 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment