Reputation: 1019
When you install a chart with a child chart that doesn't specify a namespace, Helm will use the one specified on command line via --namespace
. Is it possible to override this flag for a specific child chart?
For example if I have chart A which depends on chart B and I specify --namespace foo
, I want to be able to customize the resources of chart B to be installed into some other namespace bar
instead of foo
.
Upvotes: 41
Views: 105426
Reputation: 6236
Update 2: Helm 3 added support for multi namespaces https://github.com/helm/helm/issues/2060 (however this does not enable implicit installation of a child chart into a different namespace from the parent chart without using the explicit namespace approach mentioned in Update 1 on all of the child chart's resources).
Update 1:
If a resource template specifies a metadata.namespace
, then it will be installed in that namespace. For example, if I have a pod with metadata.namespace: x
and I run helm install mychart --namespace y
, that pod will be installed in x. I guess you could use regular helm templates with the namespace to parameterize it.
Original answer:
We do not plan on fully supporting multi-namespaced releases until Helm 3.0 https://github.com/kubernetes/helm/issues/2060#issuecomment-306847365
As a workaround, you install for each namespace individually using --skip-dependencies
or with dependency conditions
Upvotes: 38
Reputation: 652
If you already have different charts then you can use helmfile to achieve this.
Step 1: create the following folder.
my-awesome-infrastructure/
helm
helmfile
helmfile.yaml
Where helm and helmfile are the binary executables.
Step 2: install the helm diff plugin which is needed used helmfile.
helm plugin install https://github.com/databus23/helm-diff
Step 3: declare your charts in the helmfile.yaml
.
helmBinary: ./helm
repositories:
- name: ingress-nginx
url: https://kubernetes.github.io/ingress-nginx
- name: bitnami
url: https://charts.bitnami.com/bitnami
releases:
- name: nginx-ingress
namespace: nginx-ingress
createNamespace: true
chart: ingress-nginx/ingress-nginx
version: ~4.1.0
- name: jupyterhub
namespace: jupyterhub
createNamespace: true
chart: bitnami/jupyterhub
version: ~1.1.12
- name: metrics-server
namespace: metrics-server
createNamespace: true
chart: bitnami/metrics-server
version: ~5.11.9
Step 4: run helmfile to deploy all charts.
./helmfile apply
In the above example, you are deploying three separate charts to three separate namespaces.
Under the covers, helmfile
will run helm
install separately and create separate releases.
Upvotes: 5