How to override the Release.namespace for subcharts?

Viewed 2756

I have a parent chart which contains 4 subcharts, out of these I want to deploy the 1 specific subchart to different namespace and all the template files in that subchart are referring to {{ .Release.Namespace. }}. Is their any way to modify the .Release.Namespace. of subchart from the parent chart?

1 Answers

I don't believe this is possible using vanilla Helm and charts you don't control.

When a chart depends on a subchart, there's fairly little that it's possible to customize. The parent chart can provide a default set of values for the subchart, but nothing computed, and those can be overridden by the person running helm install.

If, and only if, the subchart is specifically written to deploy into an alternate namespace

# Every object in the subchart must have this configuration
metadata:
  namespace: {{ .Values.namespace | default .Release.Namespace }}

then you could supply that value to the subchart; but this isn't a default configuration.

My general experience has been that Helm "umbrella charts" are inflexible in a couple of important ways. There are higher-level tools like Helmfile and Helmsman that provide a single-command installation of multiple Helm charts with a full set of options (Helmsman is simpler, Helmfile allows Helm-style templating almost everywhere which is both more powerful and more complex). If you need to install four charts, three into one namespace and one into another, these tools might work better.

Related