# Injecting a namespace into helm template

**URL:** <https://discuss.elastic.co/t/injecting-a-namespace-into-helm-template/284230>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Created:** [September 14, 2021, 11:49pm UTC](https://discuss.elastic.co/t/injecting-a-namespace-into-helm-template/284230 "2021-09-14T23:49:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndreyL](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andreyl/32/19365_2.png) [@AndreyL](https://discuss.elastic.co/u/AndreyL)\
**Post date:** [September 14, 2021, 11:49pm UTC](https://discuss.elastic.co/t/injecting-a-namespace-into-helm-template/284230/1 "2021-09-14T23:49:38Z")

</div>

Our Kubernetes environment is managed by Nirmata, which uses gitops for application deployments. It pulls a yaml file and creates the objects. I use the official Elasticsearch helm chart ([https://github.com/elastic/helm-charts](https://github.com/elastic/helm-charts)) to generate that yaml file:

```auto
helm template myproject elastic/elasticsearch > es.yaml

```

The problem is - templates in that helm chart don't have namespaces, but all objects in that resulting es.yaml file need to have a namespace specified (so that Nirmata creates the objects in the correct namespaces), and I can't figure out how to tell Helm to add a namespace to each object (not sure its' even possible).

Is there a way to do that with helm? Otherwise I would have to use Kustomize to generate the updated template with namespaces after I generate the template with helm, which looks like a huge overhead for a simple task

---

<div class="post-metadata">

**Author:** ![Thibault\_Richard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thibault_richard/32/50513_2.png) [@Thibault\_Richard](https://discuss.elastic.co/u/Thibault_Richard)\
**Post date:** [September 15, 2021, 9:42am UTC](https://discuss.elastic.co/t/injecting-a-namespace-into-helm-template/284230/2 "2021-09-15T09:42:19Z")

</div>

> Is there a way to do that with helm?

No. Reading [helm/helm #3553 (comment)](https://github.com/helm/helm/issues/3553#issuecomment-521424132), this doesn't seem possible if the templates don't have a `metadata.namespace` field.

They notably advertise to use `helm template | kubectl apply --namespace foo`. If that doesn't work for you, kustomize might be another option.

You could also open an issue in the repository [elastic/helm-charts](https://github.com/elastic/helm-charts) to discuss the feature.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 13, 2021, 9:42am UTC](https://discuss.elastic.co/t/injecting-a-namespace-into-helm-template/284230/3 "2021-10-13T09:42:22Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
