I used helm create myapp (Helm 3) to get started, but my chart has multiple pod deployments, each performing a different function. What would be the best way to restructure the default code for multi-pod support, especially how to change the generated selectorLabels macro? Assuming I have two deployments foo and bar.
My first step was to change values.yaml into sections:
foo:
image: fooimage:1.0
...
bar:
image: barimage:1.0
...
Also rename/copy deployment.yaml into foo.yaml and bar.yaml, and add {{- with .Values.foo }} (and .bar) to the top of them to change the scope - this way both deployment files can use .image instead of .foo.image / .bar.image.
Next I tried to modify the selector label generator:
{{- define "myapp.selectorLabels" -}}
app.kubernetes.io/name: {{ include "myapp.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
The above is used in the deployment in selector.matchLabels and template.metadata.labels, e.g.
spec:
selector:
matchLabels:
{{- include "myapp.selectorLabels" . | nindent 6 }}
With the scope changed, I had to use $ instead of the ., but that generates identical labels for both deployments. What would be the recommended way to generate labels differently for each pod, while maybe prefixing them with the chart name, perhaps like this?:
spec:
selector:
matchLabels:
app.kubernetes.io/name: myapp
app.kubernetes.io/instance: myapp
app.kubernetes.io/component: foo