<p>So I'm dealing with a structure like this:</p>
<pre><code>.
├── 1
│   ├── env-vars
│   └── kustomization.yaml
├── 2
│   ├── env-vars
│   └── kustomization.yaml
├── env-vars
├── kustomization.yaml
└── shared
    ├── env-vars
    └── kustomization.yaml
</code></pre>
<p>while env-vars within each level has some env vars and</p>
<pre><code>$cat kustomization.yaml
bases:
- 1/
- 2/

namePrefix: toplevel-

configMapGenerator:
  - name: env-cm
    behavior: merge
    envs:
    - env-vars
</code></pre>
<pre><code>$cat 1/kustomization.yaml
bases:
- ./../shared

namePrefix: first-

configMapGenerator:
  - name: env-cm
    behavior: merge
    envs:
    - env-vars
</code></pre>
<pre><code>$cat 2/kustomization.yaml
bases:
- ./../shared

namePrefix: second-

configMapGenerator:
  - name: env-cm
    behavior: merge
    envs:
    - env-vars
</code></pre>
<pre><code>$cat shared/kustomization.yaml
configMapGenerator:
  - name: env-cm
    behavior: create
    envs:
    - env-vars
</code></pre>
<p>I'm essentially trying to create 2 configmaps with some shared values (which are injected from different resources: from <code>shared</code> directory and the top-level directory)</p>
<hr />
<p><code>kustomize build .</code> fails with some conflict errors for finding multiple objects:</p>
<pre><code>Error: merging from generator &lt;blah&gt;: found multiple objects &lt;blah&gt; that could accept merge of ~G_v1_ConfigMap|~X|env-cm
</code></pre>
<p>Unfortunately I need to use <code>merge</code> on the top-level <code>configMapGenerator</code>, since there are some labels injected to <code>1</code> and <code>2</code> configmaps (so <code>create</code>ing a top-level configmap altho addresses the env-vars, but excludes the labels)</p>
<p>Any suggestion on how to address this issue is appreciated</p>

Mahyar
<p>I believe this should solve your issue.</p>
<p><code>kustomization.yaml</code> which is located in <code>base</code> or <code>/</code>:</p>
<pre><code>$ cat kustomization.yaml 
resources:
- ./1
- ./2

namePrefix: toplevel-

configMapGenerator:
  - name: first-env-cm
    behavior: merge
    envs:
    - env-vars
  - name: second-env-cm
    behavior: merge
    envs:
    - env-vars
</code></pre>
<p>With help of search I found <a href="https://github.com/kubernetes-sigs/kustomize/issues/1442" rel="nofollow noreferrer">this github issue</a> which is I'd say the same issue. And then a pull-request with <a href="https://github.com/kubernetes-sigs/kustomize/pull/1520/files#diff-c1e6b6a8ce9692d830228e40df4a604cf063ef54ca54e157f70981557e72f08bL606-R609" rel="nofollow noreferrer">changes in code</a>. We can see that during <code>kustomize</code> render merge behaviour was changed to look for <code>currentId</code> instead of <code>originalId</code>. Knowing that we can address to exact &quot;pre-rendered&quot; configmaps separately.</p>
