<p>kustomize build --enable-helm .I have the following project structure:</p>
<pre><code>project
  - helm-k8s
   - values.yml
   - Chart.yml
   - templates
    - base
      - project-namespace.yml
      - grafana
        - grafana-service.yml
        - grafana-deployment.yml
        - grafana-datasource-config.yml
      - prometheus
        - prometheus-service.yml
        - prometheus-deployment.yml
        - prometheus-config.yml
        - prometheus-roles.yml
      - kustomization.yml
    - prod
      - kustomization.yml
    - test
      - kustomization.yml
</code></pre>
<p>I'm trying to build my kustomization file using helm like below:</p>
<pre><code>project/helm-k8s/templates/base/$ kubectl kustomize build . --enable-helm -&gt; dummy.yml
</code></pre>
<p>I get an error message like this:</p>
<pre><code>project/helm-k8s/templates/base$ kubectl kustomize . --enable-helm
error: accumulating resources: accumulation err='accumulating resources from 'project-namespace.yml': missing metadata.name in object {{v1 Namespace} {{ } map[name:] map[]}}': must build at directory: '/home/my-user/project/helm-k8s/templates/base/project-namespace.yml': file is not directory
</code></pre>
<p>Is it not possible for kustomize to use the values.yml which is located directly under helm-k8s folder and create the final manifest for my cluster? What am I doing wrong here?</p>
<p>EDIT: Here is how my kustomization.yml looks like:</p>
<pre><code>apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
  name: open-electrons-monitoring-kustomization
resources:
  # 0. Get the namespaces first
  - project-namespace.yml

  # 1. Set up monitoring services (prometheus)
  #- monitoring/prometheus/prometheus-roles.yml
  - prometheus/prometheus-config.yml
  - prometheus/prometheus-roles.yml
  - prometheus/prometheus-deployment.yml
  - prometheus/prometheus-service.yml

  # 2. Set up monitoring services (grafana)
  - grafana/grafana-datasource-config.yml
  - grafana/grafana-deployment.yml
  - grafana/grafana-service.yml
</code></pre>

<p>I think you may have misunderstood the use of the <code>--enable-helm</code> parameter. It does not allow kustomize to perform helm-style templating on files, so when you write:</p>
<pre><code>apiVersion: v1
kind: Namespace
metadata:
  name: {{ .Values.app.namespace }}
  labels:
    name: {{ .Values.app.namespace }}
</code></pre>
<p>That doesn't do anything useful. It just generates invalid YAML output.</p>
<hr />
<p>The <code>--enable-helm</code> option allows you to explode Helm charts using Kustomize; see <a href="https://github.com/kubernetes-sigs/kustomize/blob/master/examples/chart.md" rel="nofollow noreferrer">here</a> for the documentation, but for example it allows you to process a <code>kustomization.yaml</code> file like this:</p>
<pre><code>apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

helmCharts:
  - name: traefik
    repo: https://helm.traefik.io/traefik
    includeCRDs: true
    releaseName: example
    version: 20.8.0
    valuesInline:
      deployment:
        replicas: 3
      logs:
        access:
          enabled: true
</code></pre>
<p>Running <code>kubectl kustomize --enable-helm</code> will cause kustomize to fetch the helm chart and run <code>helm template</code> on it, producing YAML manifests on stdout.</p>
