I created a deployment in Kubernetes 1.9 running on GKE that makes use of secrets put into environment variables. I uploaded the secrets into GKE using a yaml file with the secrets base64 encoded.
What I'm seeing in my container is that the environment variable is there, but the value includes trailing whitespace. Here's what it would look like if I set up an environment variable FOO with the value "bar", where the base64 I put in the secrets yaml would be "YmFyCg==":
$ echo $FOO
bar
$ echo \"$FOO\"
"bar "
$ echo $FOO | base64
YmFyCg==
$ echo "$FOO" | base64
YmFyIAo=
This is causing no end of difficulties for applications that read from environment variables expecting the value to be encoded without the additional whitespace, e.g., POSTGRES_PASSWORD
and POSTGRES_USER
in the postgres:9.6
image. Other variables in the environment (including those set from my deployment yaml without secrets) do not include the trailing whitespace; it's only secrets that have the problem.
Your echo is adding the newline. Add -n to omit a trailing newline