I'm completely new to helm/k8s. Following question might not be best way to do things or it might not make a lot of sense, but I don't know best(or any other) practices yet, and this is my best attempt to solve something much more complex, while not understanding it properly. Thanks(I beg) for patience with me.
In values.yaml say I have something like this:
whatever1: true
whatever2: true
myConfigs:
variantA:
test: tooSteep
variantB:
test: learningCurve
in reality it's a lot bigger, of course. Then I have some template, which I need to generate in 2 (or more) variants and I cannot use whole different configs for it, which would overwrite data in values.yaml(it's complicated). Previous solution by college who understands this more than me involves some heavy copy-pasting. What I'd like to see instead is to have one abstract template, say:
whatever1: true
whatever2: true
test: {{ .Values.myConfigs.$what.test}}
which I'd include/tpl somehow within child templates, and say how it should behave conditionally, say:
{{- $what := "variantA" -}}
{{ tpl (.Files.Get "stubs/abstract.template") . }}
The syntax is obviously wrong, and it does not work. I know this is wrong, I cannot find any way which would enable this. I don't know the correct way how to write that. What I need to do is somehow express, which part of .Values should be used in specific part of template. IIUC if I have all data in 1 file I cannot, just use tpl function, load template and pass it context of specific variant, as won't have access to whatever then. So I need to pass the broader context and somehow pass some selector.
I understand, that correct way is probably restructuring files so that I can actually work effectively with context, but that would require me to actually understand which part of configuration will have to go together every time, and I'm far from ready for this refactoring.