Requirement: deploy multiple releases of chart A to single k8s namespace
I have a complex problem with subcharts name configuration. Relations between my charts are:
A
|- B
|- C
|- D - postgres
|- E - graphql-engine
|- F - postgres
|- G - graphql-engine
And the chart of type graphql-engine can requires zero or N variables based on application which for it is (if you know this app it should be backend URL, action URL, trigger URL etc.). In instance E the variables should points to aplication C and in instance G they should points to A.
I made Helm chart for graphql-engine with this part in Deployment`s container section:
env:
{{- range $k, $v := .Values.environmentVariables }}
- name: {{ quote $k }}
value: {{ quote "$v" }}
{{- end }}
To have a right names of subcharts I am doing this in A`s variables.yaml file:
B:
C:
nameOverride: A-B-C
D:
nameOverride: A-B-C-D
E:
nameOverride: A-B-C-E
F:
nameOverride: A-F
G:
nameOverride: A-G
Default chart`s _helpers.tpl file prefixs nameOverride variable with .Release.Name variable. It is not nice and optimal but I did not find a way to made this process to be dynamically created. Is here someone who knows better way to do this naming? That is my first question.
To simplify my problem. I need to put variable list like this:
into E chart from A chart. But I did not find a way to let Go templating expand .Release.Name variable. I made this in A variables.yaml:
B:
C:
nameOverride: A-B-C
D:
nameOverride: A-B-C-D
E:
nameOverride: A-B-C-E
extraVariables:
VAR1: "http://{{ .Release.Name }}-A-B-C:8080/graphql"
VAR2: "http://{{ .Release.Name }}-A-B-C:8080/actions"
F:
nameOverride: A-F
G:
nameOverride: A-G
extraVariables:
VAR1: "http://{{ .Release.Name }}-A:8080/graphql"
But I did not find a way how to use tpl Helm function in range part with dollar variable input. Or another possibility to accomplish this. I tried just include some "template" which I can made in A chart but it had bad Vars context and is used in every graphql-engine chart instance and it is not right in this.
The real A application have more levels of dependencies but it is not important to this problem. Is this wrong way to do that? How are you creating names of k8s objects and how are you setting URL variables for you applications?
Thank you!