#kubernetes #helm

app helm-templexer

Render Kubernetes Helm charts for multiple environments with explicit config while keeping the overhead at ease

10 releases

0.2.7 Jun 9, 2021
0.2.6 Apr 16, 2021
0.2.2 Jan 5, 2021
0.1.1-alpha Jul 27, 2020

#89 in Command line utilities

Download history 3/week @ 2021-03-02 3/week @ 2021-03-09 10/week @ 2021-03-23 15/week @ 2021-03-30 5/week @ 2021-04-06 66/week @ 2021-04-13 24/week @ 2021-04-20 1/week @ 2021-04-27 11/week @ 2021-05-04 10/week @ 2021-05-11 14/week @ 2021-05-18 25/week @ 2021-06-08

52 downloads per month

MIT license

38KB
669 lines

⎈ Helm Templexer

Render Helm charts for multiple environments with explicit config while keeping the overhead at ease.

All paths in the workload config are relative to callers working directory.

cat > my-app.toml <<EOF
version = "v1"
chart = "tests/data/nginx-chart"
release_name = "my-app"
output_path = "manifests"

[[deployments]]
name = "edge-eu-w4"
EOF

helm-templexer render my-app.toml

Outcome:

❯ exa -TL3 manifests
manifests
└── edge-eu-w4
   └── my-app
      └── nginx-chart

Configuration

Configuration can be provided as TOML, YAML or JSON - please also see the examples.

Please mind that all paths are evaluated relative to the working directory you call helm-templexer from.

Parameter Description Condition Default Example
version Schema version to use required "v1"
helm_version SemVer version constraint to require optional ~3
enabled Whether to render deployments or not optional true
chart Path to the chart to render required "path/to/some-chart"
namespace Namespace to pass on to helm; when omitted, no namespace is passed optional ""
release_name Release name to pass to helm required "some-release"
output_path Base path to use for writing the manifests to disk.

The fully-qualified output path is built as follows (config refers to the top-level):
config.output_path/deployment.name/<[config/deployment].release_name>

Ignore if --stdout is passed to render, however the field remains required in the configuration file as of now.
required
additional_options Pass additional options to helm template; you can use all supported options of the tool.

Common use case: use --set-string to provide a container tag to use.
This can be achieved by modifying the configuration file in your build pipeline using toml-cli, yq, jq
optional [] ["--set-string image.tag=42"]
values A list of base value files which are passed to each helm template call.
This is commonly used to provide a sane base config.
optional []
deployments The list of deployments to render. required [[deployments]]
name = "edge"

Deployments can override several top-level fields:

Parameter Description Condition Default Example
name Name of the deployment; only used in the output path required "edge-eu-w4"
enabled Allows for disabling individual deployments optional true
release_name Override the release name optional ""
additional_options Additional options, as seen above, but specific to this deployment optional []
values Value files to use for this deployment optional []

Additional Options to The Render Command

Use --additional-options to pass data to the underlying helm template call. Beware that these additional options get added to every call, i.e. to each deployment.

A common use case we found was to provide the container tag:

helm-templexer render --additional-options="--set-string image.tag=${revision}" my-app.toml

Write to stdout For Piping Into Other Tools

Use --stdout on render to write the result to stdout instead of disk.

Please mind that the output_path field in configuration version v1 remains required.

Also mind that any other logs, e.g. info logs etc, are written to stderr by default.

Installation

Docker

docker pull hendrikmaus/helm-templexer
docker run --rm --volume $(pwd):/srv --workdir /srv/tests/data hendrikmaus/helm-templexer render config_example.toml 

Include helm-templexer in your Dockerfile:

FROM hendrikmaus/helm-templexer AS helm-templexer-provider
COPY --from=helm-templexer-provider /usr/local/bin/helm-templexer /usr/local/bin

Homebrew

brew tap hendrikmaus/tap
brew install helm-templexer

Cargo Install

Helm Templexer is written in Rust. You will need rustc version 1.35.0 or higher. The recommended way to install Rust is from the official download page. Once you have it set up, a simple make install will compile helm-templexer and install it into $HOME/.cargo/bin.

If you’re using a recent version of Cargo (0.5.0 or higher), you can use the cargo install command:

cargo install helm-templexer

Cargo will build the binary and place it in $HOME/.cargo/bin (this location can be overridden by setting the --root option).

Dependencies

~4–6MB
~126K SLoC