I am trying to create a helm chart of kind ConfigMap that will replace the following command from kubernates.
kubectl create configmap my-config -n $namespace --from-file=./my-directory
my-directory
contains around 5 files, 2 of them are properties file and 2 of them jpg file. I see the following result for kubectl get cm
, I can see 4
DATA files in configMap
[admin@cluster ~]$ kubectl get cm
NAME DATA AGE
warm-up-config 4 41m
I created a template as follows, it work if I specify only properties file but If I add jpg files it doesn't work at all
apiVersion: v1
kind: ConfigMap
metadata:
name: my-config
data:
{{ (.Files.Glob "resources/*").AsConfig | nindent 2 }}
Does anyone know how I make this work.
JPG files are binary, and should be added as such.
data:
binaryData:
{{ .Files.Get "/path/to/file.jpg" }}
Files in binaryData
field must be encoded with base64, so:
{{ .Files.Get "/path/to/file.jpg" | b64enc }}
Don't forget proper indentation:
{{ .Files.Get "/path/to/file.jpg" | b64enc | nindent 4 }}