<p>I am trying to build manifest file for specific environment example:- test and I want to re-use base manifest files as mentioned below.</p>

<p>k8s/kustomize/overlays/test/kustomization.yaml</p>

<pre><code>commonLabels:
  variant: test
  app: test-app
resources:
- ../../base/deployment.yaml
- ../../base/service.yaml
- ../../base/configmap.yaml
- ../../base/secret.yaml
- namespace.yaml
namespace: app-test
patchesStrategicMerge:
- secret.yaml
- configmap.yaml
</code></pre>

<p>But I got below error when I run the command - kustomize build k8s/kustomize/overlay/test</p>

<pre><code>2020/02/19 16:04:36 got file 'deployment.yaml', but 'path/k8s/kustomize/base/deployment.yaml' must be a directory to be a root
Error: accumulating resources: accumulating resources from '../../base/deployment.yaml': security; file 'path/k8s/kustomize/base/deployment.yaml' is not in or below 'path/k8s/kustomize/overlay/test'

</code></pre>

<pre><code>P.S: kustomize version is - Version: {KustomizeVersion:3.2.0 GitCommit:a3103f1e62ddb5b696daa3fd359bb6f2e8333b49 BuildDate:2019-09-18T18:31:04+01:00 GoOs:darwin GoArch:amd64}
</code></pre>

<p>I am new to kubernetes and kustomize. Could Please help me ?</p>

shivakumar sajjan
<p>Kustomize doesn't allow you to directly include resource files that are not in the same directory or a subdirectory of where your kustomization.yml file is located.</p>
<p>The usual way to use a base in your overlay is to add a kustomization.yml file in the base and include the base directory in the kustomization.yml of your overlay. For example:</p>
<p><code>k8s/kustomize/base/kustomization.yaml</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>resources:
- deployment.yaml
- service.yaml
- configmap.yaml
- secret.yaml
</code></pre>
<p>and in <code>k8s/kustomize/overlays/test/kustomization.yaml</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>resources:
- ../../base
- namespace.yaml

namespace: app-test

commonLabels:
  variant: test
  app: test-app

patchesStrategicMerge:
- secret.yaml
- configmap.yaml
</code></pre>
