helm-kustomize-plugin

An experimental kustomize
plugin that allows to render helm charts into a kustomization.
This plugin is an improved, golang-based version of the
example chartinflator plugin
with helm built-in.
Motivation
Helm packages ("charts") provide a great way to
share and reuse kubernetes applications and there is a lot of them.
However there are some issues: For instance you cannot reuse a chart as is if
it does not (yet) support a particular parameter/value you need and
sometimes an additional kubectl
command must be run (imperative!) to install
a chart that could otherwise
be installed as a single manifest using kubectl
.
The tiller server that comes with helm has certain
issues
as well. Though helm 3 will provide some solutions to these.
Kustomize solves these issues already
declaratively by simply merging Kubernetes
API objects (which grants users of a kustomization the freedom to change anything),
by supporting all API object kinds and focussing on serverless rendering.
With helm support kustomize can be used as a generic tool to render kubernetes manifests.
These can be applied using kubectl
directly or using k8spkg
which allows to manage their state within the cluster as well.
Requirements
Install
Install using curl (linux amd64):
mkdir -p $HOME/.config/kustomize/plugin/helm.kustomize.mgoltzsche.github.com/v1/chartrenderer
curl -L https://github.com/mgoltzsche/helm-kustomize-plugin/releases/latest/download/helm-kustomize-plugin > $HOME/.config/kustomize/plugin/helm.kustomize.mgoltzsche.github.com/v1/chartrenderer/ChartRenderer
chmod u+x $HOME/.config/kustomize/plugin/helm.kustomize.mgoltzsche.github.com/v1/chartrenderer/ChartRenderer
or using go
:
go get github.com/mgoltzsche/helm-kustomize-plugin
mkdir -p $HOME/.config/kustomize/plugin/helm.kustomize.mgoltzsche.github.com/v1/chartrenderer
mv $GOPATH/bin/helm-kustomize-plugin $HOME/.config/kustomize/plugin/helm.kustomize.mgoltzsche.github.com/v1/chartrenderer/ChartRenderer
The kustomize plugin documentation
provides more information.
Usage
A plugin descriptor specifying the helm repository, chart, version and values
that should be used in a kubernetes-style resource can be referenced in the
generators
section of a kustomization.yaml
and looks as follows:
apiVersion: helm.kustomize.mgoltzsche.github.com/v1
kind: ChartRenderer
metadata:
name: <NAME>
namespace: <NAMESPACE>
repository: <REPOSITORY>
chart: <CHART_NAME>
version: <CHART_VERSION>
valueFiles:
- <VALUE_FILE>
value: <VALUE_MAP>
exclude:
- apiVersion: <APIVERSION>
kind: <KIND>
namespace: <NAMESPACE>
name: <NAME>
repository
(optional): a helm repository URL.
chart
: a chart name (using repository
) or, when repository
is not specified, a go-getter URL.
valueFiles
: a list of helm value file paths relative to the generator config file or to the chart.
exclude
: a list of selectors used to exclude matching objects from the rendered chart.
Example
Example kustomizations using this plugin can be found in the example
directory.
For instance cert-manager
can be rendered and deployed like this:
kustomize build --enable_alpha_plugins github.com/mgoltzsche/helm-kustomize-plugin/example/cert-manager | kubectl apply -f -
Compatibility & security notice
Plugin support in kustomize is still an alpha feature.
Helm charts may access the local file system outside the kustomization directory.