Skip to content

How to Decode a Secret in Kubernetes

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}'
Code language: Bash (bash)

This will output a JSON as follows:

Code language: Bash (bash)

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
Code language: Bash (bash)

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

Code language: Bash (bash)

See also  How to Deploy a Helm "Hello World" app onto Kubernetes
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x