'How to do logging with helm

Sometimes I d'like to log something while a helm templates is executed. In Java this would look something like this:

LOGGER.debbug("My value is {}", value);

There is Notes.txt, which could help in some situations. But it would be nice if I could add a logging statement for debugging purposes just at the right place in a template.



Solution 1:[1]

I don't believe Helm has anything directly like this: I don't think there's a way to write anything to stdout from a template while helm install is executing.

You already know about the NOTES.txt file. Depending on what exactly you're trying to debug, another option is to write a YAML comment into the output:

metadata:
  # chart={{ .Chart.Name }} release={{ .Release.Name }}
  name: {{ include "mychart.fullname" . }}

Go template comments {{/* ... */}} will be consumed by the template parser, but Helm isn't really aware of # ... YAML comments, and they'll be output with the rest of the template.

If this is a new project, I'd also consider writing a Go-based Kubernetes operator instead of a Helm chart if your installation logic is so complex that putting logging in your templates sounds like a good idea. Go's syntax is a little less weird, it's easier to find people who know Go than Helm, and the general software ecosystem is much richer (there are a couple of reasonably standard Go logging packages for example).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Maze