I'm currently facing a weird issue with K8S. Indeed I'm creating a container with an envFrom statement and the env variable is pulled from a secret:
envFrom:
- secretRef:
name: my-super-secret
I have created the secret with the base64 encoded value, and when I echo the variable in the container it has added a space at the end, which is quite an issue since it's a password ;-)
Here's my secret:
apiVersion: v1
kind: Secret
metadata:
name: my-super-secret
data:
DB_PASSWORD: base64encodedvalue
Does anyone could provide me with some guidance here ? I absolutely can't figure out what's happening here ...
How did you encode the value?
Using this (on Mac)
echo -n "base64encodedvalue" | base64
YmFzZTY0ZW5jb2RlZHZhbHVl
I can access my values just fine in my Containers, without a trailing space.
echo YmFzZTY0ZW5jb2RlZHZhbHVl | base64 -d
base64encodedvalue
Source: https://kubernetes.io/docs/tasks/configmap-secret/managing-secret-using-kubectl/