Can one store a binary file in a Kubernetes ConfigMap and then later read the same content from a volume that mounts this ConfigMap? For example, if directory /etc/mycompany/myapp/config
contains binary file keystore.jks
, will
kubectl create configmap myapp-config --from-file=/etc/mycompany/myapp/config
include file keystore.jks
in ConfigMap myapp-config
that can later be mapped to a volume, mounted into a container, and read as a binary file?
For example, given the following pod spec, should keystore.jks
be available to myapp
at /etc/mycompany/myapp/config/keystore.jks
?
apiVersion: v1 kind: Pod metadata: name: myapp spec: containers: - name: myapp image: mycompany/myapp volumeMounts: - name: myapp-config mountPath: /etc/mycompany/myapp/config volumes: - name: myapp-config configMap: name: myapp-config
Kubernetes version details:
derek@derek-HP-EliteOne-800-G1-AiO:~/Documents/platinum/fix/brvm$ kubectl version Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.6", GitCommit:"ae4550cc9c89a593bcda6678df201db1b208133b", GitTreeState:"clean", BuildDate:"2016-08-26T18:13:23Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.6+coreos.0", GitCommit:"f6f0055b8e503cbe5fb7b6f1a2ee37d0f160c1cd", GitTreeState:"clean", BuildDate:"2016-08-29T17:01:01Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}
Binary ConfigMaps are now supported since Kubernetes version 1.10.0. From the readme notes:
ConfigMap objects now support binary data via a new binaryData field. When using kubectl create configmap --from-file, files containing non-UTF8 data will be placed in this new field in order to preserve the non-UTF8 data. Note that kubectl's --append-hash feature doesn't take binaryData into account. Use of this feature requires 1.10+ apiserver and kubelets. (#57938, @dims)
See the changelog for more details: https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.10.md#apps
What I would do is encode this file in base64 and then the container that uses decoded to be able to use it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With