I'm trying to create a helper chart which serves file content to other charts. Basically, since I have pretty much the same logging.xml
configuration for all my apps I would like to define it at one place and share between the app charts.
So far I've managed to create a template:
{{- define "helpers.logging.xml" -}}
logback.xml: |-
{{ .Files.Get "resources/logback.xml" }}
{{- end }}
File structure in the helper chart looks like this:
helpers
|--templates
|--_helpers.tpl
|-resources
|--logback.xml
Chart.yaml
In the main chart I try to pass results of the template. But it only works if I have a resouses/logging.xml
file in the app chart itself.
apiVersion: v1
kind: ConfigMap
metadata:
name: logging.{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
data:
{{ include "helpers.logging.xml" . }}
Can someone advise me what is wrong? It it actually possible to do such a thing with Helm?
So in the end I found a soluton which suits my needs. Instead of sourcing from resource file I created an extra helper with a single template like this:
{{- define "templates.logback.xml" -}}
logback.xml: |-
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- default configuration goes here -->
<!-- ... -->
<!-- include custom config -->
<include file="logback-custom.xml"/>
</configuration>
{{- end }}
In a chart I have a configMap configured like this:
apiVersion: v1
kind: ConfigMap
metadata:
name: logging.{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
data:
{{ include "templates.logback.xml" . }}
logback-custom.xml: |
<included>
<!-- custom config -->
</included>