26

With Kubernetes 1.10.* we can use binaryData: with ConfigMap and I am trying to combine it with Helm:

apiVersion: v1
kind: ConfigMap
metadata:
  name: some_config_map
data:
  text_data: |-
    {{ .Files.Get "truststores/simple_text_file.txt" }}
binaryData:
  trustore.jks: |-
    {{ .Files.Get "truststores/trustore.jks" | b64enc }}

I am not sure about the last line - regardless of syntax:

 {{ "truststores/trustore.jks" | b64enc }}
 {{ "truststores/trustore.jks" }}

the trustore.jks is empty when I deploy it.

So how can I use binaryData: ?

Jim Counts
  • 12,535
  • 9
  • 45
  • 63
pb100
  • 736
  • 3
  • 11
  • 20

3 Answers3

17

Your syntax looks fine and everything should work properly. Files in the field binaryData must be encoded with base64, so, {{ .Files.Get "truststores/trustore.jks" | b64enc }} is correct.

Try to apply the configuration with debug key and investigate what went wrong, possibly there is no such file or there are some problems with encoding.

Artem Golenyaev
  • 2,568
  • 12
  • 20
9

This might be too late, but maybe it will help someone.

You need to add indentation to your base64 encoded string.

{{ .Files.Get "truststores/trustore.jks" | b64enc | indent 4}}

This is also applies to your text file:

{{ .Files.Get "truststores/simple_text_file.txt" | indent 4}}

This should add 4 spaces to each line from the file

0

Syntax is good but as defined here https://helm.sh/docs/chart_template_guide/accessing_files .Files don't load file from anywhere. So "truststores/trustore.jks" if truststores is not part of your chart folder

jandry
  • 170
  • 2
  • 7