kustomize-controller
kustomize-controller copied to clipboard
Enable variable substitution on individual objects
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 !"
The Kustomize ConfigMap generator allows you to set annotations on the generated objects, so you can set it once for all configs.
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.