3

The standard practice in helm charts is to use {{ template "<chartname>.fullname" . }} for the service name, where the <chartname>.fullname template expands effectively to .Release.Name-.Chart.name. The later can be overridden by .Values.nameOverride, but the former, or the full value, can't. And the former is either administrator-specified or random.

So how do I tell the service I am creating chart for where to connect to its dependencies? The .Release.Name prefix infects both DNS and the environment variables, so I can't use either as is.

For example if I set dependency to stable/mariadb, it will create service like nutty-narwhal-mariadb and provide environment variables NUTTY_NARWHAL_MARIADB_SERVICE_HOST=10.108.77.204 and NUTTY_NARWHAL_MARIADB_SERVICE_PORT=3306. But that's not helpful, because the service I am creating does not know what the prefix is.

Note that the template generated by current helm create does include .Values.fullnameOverride, but the existing charts in main repository like stable/mariadb don't have it, so I can't simply set mariadb.fullnameOverride in my values.yaml.

Jan Hudec
  • 265
  • 3
  • 11

1 Answers1

1

Normally your dependencies would be aggregated under the same "umbrella" chart resulting in a single .Release.Name for all of them, meaning that you will be able to point to them in your chart using stuff like .Release.Name-<subchart>. If for some reason you don't want to do it like this and you deploy your dependencies before you deploy your main chart, then you should be able to point them at the location of dependencies by their provisioned name, as you should get it when you installed them.

  • Ok, I understand. So it's making my life harder, while not supporting the only case where I can imagine it could be useful—having multiple instances of the same dependency (e.g. two services that each needs its own database). – Jan Hudec Mar 06 '18 at 09:52
  • 1
    actually it supports it pretty well by subchart aliasing – Radek 'Goblin' Pieczonka Mar 06 '18 at 11:19
  • However, that changes the `.Chart.Name`, so it does not need the `.Release.Name` prefix for that anyway, right? Anyway, I found [this discussion](https://github.com/kubernetes/helm/issues/2060) where several people ask for the same thing. – Jan Hudec Mar 07 '18 at 12:32
  • .Release.Name is what you need as a prefix, as this is the part that does not change regardless of subchart you're in. With that you have a "root" to which you can append hardcoded subchart name. – Radek 'Goblin' Pieczonka Mar 07 '18 at 12:57
  • I understand that. It just complicates everything, because then everything has to read name of everything else from configuration when otherwise it could simply have it included in its configuration. For components that will be included in other applications it doesn't really matter, because the names must be configurable anyway, but for the end application they don't. Anyway, the modern charts have fullnameOverride, so the application chart can just set it and not use the prefix if it has no use for it. And I am going to tweak the dependency charts anyway. – Jan Hudec Mar 08 '18 at 15:22