Description
I’m facing an issue when trying to create a Secret in Kubernetes with a password that contains the special character & using the kubectl create secret command. The password is either being encoded incorrectly or not handled properly when the special character is included.
Here’s the command I’m trying to execute:
kubectl create secret docker-registry docker-login-secret10
--docker-server=
registry.example.com
--docker-username=mke_prod
--docker-password="5a6g(07hl9gsv&QzF9Fgcrz@6rnHA4h7"
--docker-email=[email protected]
--namespace=default
The secret creation seems to work correctly, but when I decode the .dockerconfigjson field, the password appears in the format
"password": "5a6g(07hl9gsv\u0026QzF9Fgcrz@6rnHA4h7"
Expected result:
"password": "5a6g(07hl9gsv&QzF9Fgcrz@6rnHA4h7"
Actual result:
"password": "5a6g(07hl9gsv&QzF9Fgcrz@6rnHA4h7"
"&" character is being encoded as \u0026 or another incorrect value, which is not the expected behavior.
What I’ve tried:
Escaped the & using & in the command, but it didn't work.
Tried using single and double quotes around the password, but the issue persists.
Checked the base64 encoding, but the special character seems to be handled incorrectly.