#kubernetes #helm

app helm-templexer

Render Kubernetes Helm charts for multiple environments with _explicit config_ while keeping the overhead at ease

24 releases (9 stable)

2.0.7 May 9, 2023
2.0.6 Dec 19, 2022
2.0.1 Sep 27, 2022
2.0.0 Sep 9, 2021
0.1.1-alpha Jul 27, 2020

#1 in #helm

Download history 21/week @ 2023-08-14 1/week @ 2023-08-21 21/week @ 2023-08-28 50/week @ 2023-09-04 2/week @ 2023-09-11 1/week @ 2023-09-18 3/week @ 2023-09-25 76/week @ 2023-10-02 121/week @ 2023-10-09 65/week @ 2023-10-16 6/week @ 2023-10-23 38/week @ 2023-10-30 3/week @ 2023-11-13 25/week @ 2023-11-20 72/week @ 2023-11-27

101 downloads per month

MIT license

907 lines

⎈ Helm Templexer


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

The helm-templexer wraps Helm v3+, please ensure that it is installed and in the PATH.

cat > my-app.yaml <<EOF
version: v2
chart: tests/data/nginx-chart
release_name: my-app
output_path: manifests
  - name: edge
  - name: stage
  - name: prod

helm-templexer render my-app.yaml


❯ exa -T manifests
├── edge
│  └── my-app
│     └── manifest.yaml
├── prod
│  └── my-app
│     └── manifest.yaml
└── stage
   └── my-app
      └── manifest.yaml


Configuration can be provided as YAML format.

All paths are evaluated relative to the configuration file during execution.

Looking for schema v1? Please see helm-templexer 1.x.

Parameter Description Condition Default Example
version Schema version to use required "v2"
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):
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 mikefarah/yq
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

Extending The helm template Call

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.yaml

Render a Subset of Deployments

Use --filter to render a specific deployment. Example: To render only the prod, pass the regex to the filter option.

helm-templexer render --filter="prod" my-app.yaml

Update Helm Dependencies Before Rendering

Use --update-dependencies to run helm dependencies update once before starting to render the deployments.

helm-templexer render --update-dependencies my-app.yaml

Pipe Manifest Output Through Tool(s) Before Writing to Disk

Use --pipe to pass the manifest output through a tool or set of tools before writing to a file.

Please mind that this option requires an equal sign (=), i.e. `--pipe="".

helm-templexer render --pipe="kbld -f -" my-app.yaml

You can define the argument multiple times; the commands will be added in order of appearance to the final command.

helm-templexer render --pipe="kbld -f -" --pipe="tee /dev/stdout" my-app.yaml

If anything unexpected happens, you can use -v, -vv and -vvv to increase the log level and see the underlying command.



# create the directory where helm-templexer will render to
mkdir -p tests/data/manifests

# let helm-templexer's user id (1001) own the directory
sudo chown -R 1001 tests/data/manifests

# pull and run the image
docker pull ghcr.io/hendrikmaus/helm-templexer
docker run --rm --volume $(pwd):/srv --workdir /srv/tests/data ghcr.io/hendrikmaus/helm-templexer render config_example.yaml 

Include helm-templexer in your Dockerfile:

FROM ghcr.io/hendrikmaus/helm-templexer AS helm-templexer-provider
COPY --from=helm-templexer-provider /usr/bin/helm-templexer /usr/bin
COPY --from=helm-templexer-provider /usr/bin/helm /usr/bin

Pre-compiled Binary

Please set/replace $TARGET and $VERSION accordingly.

wget https://github.com/hendrikmaus/helm-templexer/releases/download/v$VERSION/helm-templexer-$VERSION-$TARGET.tar.gz -O - | tar xz && mv helm-templexer /usr/bin/helm-templexer

For example VERSION=2.0.0 and TARGET=aarch64-apple-darwin

The mv to /usr/bin might require sudo.

Validate Against Checksum

To validate the downloaded archive against the checksum:

wget https://github.com/hendrikmaus/helm-templexer/releases/download/v$VERSION/helm-templexer-$VERSION-$TARGET.tar.gz
echo "$(wget https://github.com/hendrikmaus/helm-templexer/releases/download/v$VERSION/helm-templexer-$VERSION-$TARGET.tar.gz.sha256 -O -) helm-templexer-$VERSION-$TARGET.tar.gz" | sha256sum --check --strict --status


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).


~265K SLoC