Templates

Kapps can include golang templates to make it easy to use variables to configure the underlying commands that are executed for each run phase. For example, templating a Helm values.yaml file makes it easy to configure the Helm chart dynamically with variables specific to the stack.

Each template is defined as:

  • source (required) - path to the source template. The path will be searched for first in the kapp (relative to the directory containing the kapp’s sugarkube.yaml file), then in any directories configured in the stack’s kapp_vars_dirs setting
  • dest (required) - the path to write the templated file to, relative to the kapp’s sugarkube.yaml file
  • conditions - a list of conditions that must all evaluate to true for the template to be rendered

The conditions block allows you to only render templates in certain situations. As an example our Wordpress kapp only renders certain files when targetting AWS.

Sugarkube retemplates files multiple times during an installation/deletion. If you edit a rendered template it’s highly likely to be overwritten by a rerendered version, so make sure you do all your edits in the source template.