<p>I have an application with different versions. The base resource file for each version is slightly different. But the patch which needs to be applied to the base file is same. What should be the best structure to apply the same patch to different base resource and have different output files respectively.</p>
<pre><code>/base1/
     /app-v1
     /kustomization.yaml
/base2/
     /app-v2
     /kustomization.yaml
/overlays/
     /dev/      
     /staging/ 
</code></pre>
<p>How should I specify the resource to make the overlay and patch in base kustomization.yaml which are same to v1 and v2 apply to the different base files?</p>
<p>Ideally, use different <code>kustomize build</code> command for different base but using same patch file.</p>

JoyceLee
<p>One way to do it would be to have a kustomization file in <code>/overlays/</code>, including patches and configurations from <code>dev/</code> and <code>staging/</code>. Eg:</p>
<pre><code>$&gt; cat ./overlays/kustomization.yaml
resources:
- ./dev/foo.yaml
- ./staging/bar.yaml

patchesJson6902:
- target:
    version: v1
    groups: apps
    kind: Deployment
    name: my-app
  patch: ./dev/patch-deploy.yaml
</code></pre>
<p>And include that <code>overlays</code> folder from your base1 and base2 kustomization:</p>
<pre><code>$&gt; cat ./base1/kustomization.yaml
resources:
- ./app-v1/stuff.yaml
- ../overlays/
[...]
$&gt; cat ./base2/kustomization.yaml
resources:
[...]
- ../overlays/
</code></pre>
<p>Then, you can run kustomization from either base folder, while they would all process the content of your overlays folder.</p>
