How can i upload Binary file like cert file as Config-map
I am trying to upload Cert file like .p12 as config map but it's failing every time. After upload i do not see the file just entry.
Command that i used:
oc create configmap mmx-cert --from-file=xyz.p12
Failed.
Also used:
oc create configmap mmx-cert--from-file=game-special-key=example-files/xyz.p12
Also failed.
This is how i done.
1) Adding the cert to stage CAE:
With the cert in the same directory as you are running the oc command:
oc create secret generic mmx-cert --from-file='cert.p12'
2) Add the secret volume:
The next step is to create a volume for the secret. As a test, I was able to use the oc command to create the volume on the apache nodes. Since the apache nodes have a deployment config, it was straight forward. I took that test setup, and manually added it to the app pods. The pieces I added to the deployment yaml were:
- mountPath: /opt/webserver/cert/nonprod/
name: mmxcert-volume
- name: mmxcert-volume
secret:
defaultMode: 420
secretName: mmx-cert
3) Verify the cert
md5sum cert.p12
Not sure what's the command oc
, but if you are talking about kubectl
, please make sure you feed the proper parameter
kubectl create configmap mmx-cert --from-env-file=path/to/xyz.p12
Please go through help
as well, the parameter --from-file
is based on folder, not file.
$ kubectl create configmap --help
...
# Create a new configmap named my-config based on folder bar
kubectl create configmap my-config --from-file=path/to/bar
You cannot, ConfigMaps cannot contain binary data on their own. You will need to encode it yourself and decode it on the other side, usually base64. Or just a Secret instead, which can handle binary data.