Injecting a namespace into helm template

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) to generate that yaml file:

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

Is there a way to do that with helm?

No. Reading helm/helm #3553 (comment), 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 to discuss the feature.

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