Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes/Helm: any examples with ConfigMap and "binaryData:"?

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: ?

like image 763
pb100 Avatar asked Jul 14 '18 11:07

pb100


2 Answers

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.

like image 126
Artem Golenyaev Avatar answered Oct 14 '22 21:10

Artem Golenyaev


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

like image 29
Stanciu Marian Madalin Avatar answered Oct 14 '22 22:10

Stanciu Marian Madalin