Helm charts nested loops
I think you should reconsider the way the data is structured, this would work better:
services: - name: backend settings: port: 80 targetPort: 8080 replicaCount: 1 environmentVariables: - name: SOME_VAR value: "hello" - name: web settings: port: 80 targetPort: 8080 replicaCount: 1 environmentVariables: - name: SOME_VAR value: "hello"
And your Deployment to look like this:
{{- range .Values.services }}---apiVersion: apps/v1beta1kind: Deploymentmetadata: name: myapp-{{ .name }}spec: replicas: {{ .settings.replicaCount }} template: metadata: labels: app: myapp-{{ .name }} spec: containers: - name: myapp-{{ .name }} image: {{ $.Values.containerRegistry }}/myapp-{{ .name }}:latest ports: - containerPort: {{ .settings.targetPort }} env: {{- with .settings.environmentVariables }} {{ toYaml . | trim | indent 6 }} {{- end }} imagePullSecrets: - name: myregistry{{- end }}
would actually create two deployments, by adding the ---
separator.