kustomize: Error when composing several identical bases that use the same var: "var ... already encountered"
Here is a reduced test case and README: https://github.com/gobengo/kustomize-issue-7f53131c-0253-45a9-87c4-c6ab2f4d55ea
If you run kustomize build . in the root directory, you get an error like:
Error: accumulating resources: recursed merging from path '2cbace6b-c9f0-4f56-aba7-b911c0c85d48': var 'MYSQL_SERVICE' already encountered
The var referenced in the error message is defined in the kustomization.yaml of the (remote) base that both top-level bases use. https://github.com/gobengo/etherpad-lite/blob/master/lib/kubedb-mysql-etherpad-lite/kustomization.yaml#L6
The root directory kustomization simply composes the two directories in here (which are identical and both use etherpad-lite as a base).
kustomize build in either of the base directories works fine and produces a stream of yaml output (try ls -d */ | xargs -L1 kustomize build).
Expected Behavior: I can kustomize build . in the root directory and there is no error and I see the same output as concatenating the outputs of the two bases (joined with ‘—’).
It seems like this should work. My goal is just to have the same remote kustomization running in two different namespaces. I also want the remote kustomization to surive namePrefix so it can be used twice in the same namespace (which is why I’m using vars for the service name). Is this a bug or am I missing something about how vars should work?
EDIT:
- I tested with kustomize 2.1.0
Update 20190807: I tested with kustomize 3.1.0 and the same error happens: kubectl kustomize github.com/gobengo/kustomize-issue-7f53131c-0253-45a9-87c4-c6ab2f4d55ea.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 20 (8 by maintainers)
This also happens when composing multiple different kustomizations (not just multiple identical bases) which use the same variable name. Specifically, when trying to apply kustomizations generated by https://github.com/kubeflow/kfctl by listing them as bases in a top-level kustomization.yaml, multiple of them include a variable called
clusterDomain. Variables created in “sibling” kustomizations shouldn’t interfere with each other.Our project is needing that feature. Also the PR had been left rotten for four months, like a lot of things we have to maintain the fork until a feature matching that need is actually implemented in kustomize.
So if you check here you will see that is actually work.
To gain access to the feature, just clone the allinone branch and run “make install”.
There isn’t one gh-1620 contains the fix but we can’t merge it unless we ignore the other issue it creates.