I'm trying to add mysql root password as a secret to my kubernetes deployment and it doesn't seem to be picking it up. This is what I have
deployment:
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-root
key: mysql-root-passwd
secret:
kubectl create secret generic mysql-root --from-literal=mysql-root-passwd=steve
but when I go into the pod the mysql root password for % and localhost is always the same:
*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19
which is 'password'
in Base64 decode
What am I doing wrong? when I set the password in the deployment file it works just fine but I'd prefer not to have it there.
I always create using the yml
file with create -f
command and it accepts base64
encoded string.
Please check using base64 of your password and get the secret as yaml.
See link: https://kubernetes.io/docs/concepts/configuration/secret/
You could try
kubectl create secret generic mysql-root \
--from-literal=mysql-root-passwd=steve --dry-run -o yaml | kubectl apply -f -
as I don't think you can create when it already exists