How do I give a newline in a user-defined environment variable for openshift deployment

7/22/2019

I'm trying to give a openssl certificate through environment variable. The problem is that openshift is converting the line break to a space and the verification of certificate gets failed. Could you provide a way to get line breaks in the environment variable. Or a way to correctly read the certificate.

-- Abc
kubernetes-pod
openshift

1 Answer

7/22/2019

How about you encode the certificates as base64 first ?

For example, you use double quotes for env variable to set certificates.

# oc set env dc/test1 CERT="$(cat /path/to/certificates.crt|base64)"

When you refer the certificates, you decode the value to remain the new lines. (Required to use double quotes either)

# oc rsh dc/test1
sh-4.2$ echo "$CERT" | base64 -d
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
-- Daein Park
Source: StackOverflow