I'm trying to do somewhat advanced templating. But not able to progress so far.
The idea is to get the config/file.conf to template the values properly while doing a loop in configmap file. I've added the respective code snippet for your reference.
Any help is appreciated.
Values.yaml
global:
teacher: bob
class:
primary:
name: rajesh
teacher: {{.Values.global.teacher}}
secondary:
name: job
teacher: {{.Values.global.teacher}}
config/file.conf
name={{ .name }}
teacher={{ .teacher }}
templates/configmap.yaml
{{- $currentScope := .}}
{{- range $jobName, $jobData := .Values.class }}
{{- if $jobData.enabled }}
{{- with $currentScope }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $jobName }}
data:
{{- range $path, $_ := .Files.Glob "config/*" }}
{{ base $path | nindent 2 }}: |-
{{- with $currentScope }}
{{- $var := .Files.Get $path }}
{{- include "common.tplvalues.render" (dict "value" $var "context" $) | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Chart.yaml
apiVersion: v2
name: ch
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"
dependencies:
- name: common
version: 2.x.x
repository: oci://registry-1.docker.io/bitnamicharts