Nested component with reused component weird behavior #5821
Labels
kind/bug
Categorizes issue or PR as related to a bug.
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
What happened?
I want to duplicate a resource with a suffixed name and some extra fields. This is not exactly a well documented use case, but in theory with the use of
Components
it should be possible.My thought process was that I cannot just have the same component included twice as it would result in an identifier collision, so I have to sort of pre-render it inside a component - that should be more-or-less self-confined to my understanding with a big asterisk - and include that template component with slight modifications, e.g. nameSuffix, inside a wrapper component twice.
Folder structure
Component
Component
This works nicely miraculously, whether I modify both name from the "template" component, or only one rendering the
resources
.But if I want to apply patches in
dev
, it only works, if I modify both names and set up the patches according, i.e. targetapp-a
andapp-b
, and it fails withError: no resource matches strategic merge patch "Service.v1.[noGrp]/app.[noNs]": multiple matches for Id Service.v1.[noGrp]/app.[noNs]; failed to find unique target for patch Service.v1.[noGrp]/app.[noNs]
ifapp
andapp-b
is the target while only addig a-b
suffix toservice-b
in the component.If I start reasoning from the fact that name suffixes are applied after patches, then the patch should target
app
always, so the component shall indeed be pre-rendered at that stage. But then if the component is pre-rendered, there should be no name collision. It's like if the template component and the wrapper would exists at the same time in the system intermittently. It also didn't work with patching the name, which should render in the same time if my previous reasoning is flawed in the order or self encapsulation.What did you expect to happen?
I would expect the following order:
Kustomization
renderKustomization
inside the wrapperComponent
would render the template componentKustomization
inside the wrapperComponent
would run any remaining transformers, e.g. nameSuffix, patch.resources
rendered with thepatches/dev
with the now pre-rendered component(s) on top of it, effectively merging the two.In other words, I would expect it to work with only renaming one of them as well.
How can we reproduce it (as minimally and precisely as possible)?
https://github.com/CreMindES/kustomize-5821
Expected output
Actual output
Kustomize version
5.4.3
Operating system
Linux
The text was updated successfully, but these errors were encountered: