0

I have a helm deployment that includes a configmap.
I would like to add a few rather large files to it and I thought I coud put them in a an external directory

my-app/values.yaml
my-app/conf/my-large-file1.conf
my-app/conf/my-large-file2.conf
my-app/templates/configmaps.yaml

I thought I could use include but this did not work

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: example1
data:
  index.html: {{ include "/conf/my-large-file1.conf" . }}

Error:

template: my-app/templates/configmaps.yaml:23:17: executing "my-app/templates/configmaps.yaml" at <include "/conf/my-large-file1.conf" .>: error calling include: template: no template "/conf/my-large-file1.conf" associated with tem\
    plate "gotpl"

I then tried different things with {{ $.Files.Get "conf/my-large-file1.conf" }} but got weird scoping errors.

So my hope is that someone can tell me how to do it correctly

$ helm version
version.BuildInfo{Version:"v3.11.1+6.el8", GitCommit:"66bfc44f827aea6eb8e001150914170ac0d49e2d", GitTreeState:"clean", GoVersion:"go1.18.9"}

2 Answers 2

1

Try with Files.Glob , Files.AsConfig and with indentation. Similar pattern works for me ->

apiVersion: v1
kind: ConfigMap
metadata:
  name: example1
data:
{{ (.Files.Glob "conf/my-large-file1.conf").AsConfig | indent 2 }}

Files.Glob - reference

AsConfig - reference.

0

This is how I ended up solving it

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-cm
data:
  app.properties: |-
    {{- tpl ($.Files.Get "conf/app.properties.tmpl") . | nindent 4 }}

  app-users.properties: |-
    {{- tpl ($.Files.Get "conf/app-users.properties.tmpl") . | nindent 4 }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.