How to Decode a Secret in Kubernetes

0 min read 94 words

Secrets in Kubernetes are encoded using base64.

If you have the secret name, you can ask for its value. If not, then learn how to get a secret in Kubernetes.

How to retrieve the value of a secret in Kubernetes

kubectl get secret admin-user-pass -o jsonpath='{.data}'

This will output a JSON as follows:

{"password":"amYzOTJoZjc4MmhmOTMyaAo=","username":"YWRtaW51c2VyCg=="}

How to decode the value of a secret in Kubernetes

Values are always base64 encoded, so decoding it will look like this:

echo 'amYzOTJoZjc4MmhmOTMyaAo=' | base64 --decode

This prints the decoded value of our original secret we stored before.

jf392hf782hf932h
Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags