kustomize-controller icon indicating copy to clipboard operation
kustomize-controller copied to clipboard

Enable variable substitution on individual objects

Open brovoca opened this issue 1 year ago • 2 comments

We can disable variable substitution on a particular object by setting the annotation kustomize.toolkit.fluxcd.io/substitute: disabled. However, I'd like to see the inverse of this, which means that I want to opt-in for variable substitution on particular objects - since I rarely substitute, and prefer the explicit annotation.

Use case

I store Grafana dashboard JSON files and Bash shell scripts in my Flux repo which I generate into ConfigMaps using configMapGenerator. Flux will then replace all variables, no matter if they are set or not.

Thus, the following shell script:

NAME="world"
echo "Hello ${NAME}!"

... will become:

NAME="world"
echo "Hello !"

brovoca avatar May 02 '23 15:05 brovoca

The Kustomize ConfigMap generator allows you to set annotations on the generated objects, so you can set it once for all configs.

stefanprodan avatar May 02 '23 15:05 stefanprodan

I am aware, and I am currently doing so. I prefer having the variables opt-in still, as I have a feeling it could produce unexpected results for those that don't pay attention.

brovoca avatar May 02 '23 15:05 brovoca