Reputation: 4600
Is there a way I can specify the helm release to be deployed on a custom namespace. All the helm resources are deployed on a custom namespace that I created by mentioning
namespace: {{ template "plugin.namespace" . }}
and this is taken from _helper.tpl
But the release by itself is in default namespace
helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
object-storage-plugin default 3 2021-08-04 15:42:30.833512 +0530 IST deployed object-storage-plugin-2.1.2 2.1.2
I know via command line we can set the namespace but I am looking for options from a template file where the namespace would be picked
I referred https://helm.sh/docs/chart_template_guide/getting_started/
With helm3 --create-namespace
creates new namespace but helm uninstall command doesnt delete this newly created NS.
Upvotes: 1
Views: 9940
Reputation: 160053
In normal use you must use the helm install --namespace
option to specify the namespace where Helm keeps its persistent data. There's no way to specify this in a file.
Also in normal use, you wouldn't manually specify the namespace:
in individual YAML files. Resources will automatically be installed in the helm install --namespace
(in the same way as if you kubectl apply --namespace ... -f ...
). You should only need namespace:
for unusual setups where the same chart needs to install things in multiple namespaces; IME that's usually only if you're using Helm for doing cluster-level setup.
However, you also tagged this question as helmfile. If you're using Helmfile, then in the helmfile.yaml
file, you can specify the namespace to use there. The helmfile.yaml
effectively has helm install
options listed out in YAML, so you again wouldn't need to specify namespace:
in templates.
# helmfile.yaml
# (not a plain Helm artifact)
releases:
- name: object-storage-plugin
namespace: object-storage-plugin # <-- configure this
chart: ./charts/object-storage-plugin
values:
- values.dev.yaml
# `helmfile apply` will do the equivalent to
#
# helm install object-storage-plugin \
# ./charts/object-storage-plugin \
# -n object-storage-plugin \
# -f values.dev.yaml
Upvotes: 5