Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubernetes configmaps for binary file

Tags:

kubernetes

My kubernetes version is 1.10.4.

I am trying to create a ConfigMap for java keystore files:

kubectl create configmap key-config --from-file=server-keystore=/home/ubuntu/ssl/server.keystore.jks --from-file=server-truststore=/home/ubuntu/ssl/server.truststore.jks --from-file=client--truststore=/home/ubuntu/ssl/client.truststore.jks --append-hash=false

It says configmap "key-config" created.

But when I describe the configmap I am getting null value:

$ kubectl describe configmaps key-config
Name:         key-config
Namespace:    prod-es
Labels:       <none>
Annotations:  <none>

Data
====
Events:  <none>

I know my version kubernetes support binary data as configmaps or secrets but I am not sure what is wrong with my approach.

Any input on this is highly appreciated.

like image 418
user1068861 Avatar asked Jun 20 '18 15:06

user1068861


1 Answers

kubectl describe does not show binary data in ConfigMaps at the moment (kubectl version v1.10.4); also the DATA column of the kubectl get configmap output does not include the binary elements:

$ kubectl get cm
NAME           DATA      AGE
key-config     0         1m

But the data is there, it's just a poor UI experience at the moment. You can verify that with:

kubectl get cm key-config -o json

Or you can use this friendly command to check that the ConfigMap can be mounted and the projected contents matches your original files:

kubectl run cm-test --image=busybox --rm --attach --restart=Never --overrides='{"spec":{"volumes":[{"name":"cm", "configMap":{"name":"key-config"}}], "containers":[{"name":"cm-test", "image":"busybox", "command":["sh","-c","md5sum /cm/*"], "volumeMounts":[{"name":"cm", "mountPath":"/cm"}]}]}}'

like image 154
Janos Lenart Avatar answered Sep 28 '22 16:09

Janos Lenart