How To Retrieve and Decode a Kubernetes Secret

1

List all secrets in the Kubernetes cluster.

kubectl get secrets
2

Retrieve the specified key from the secret. Replace <SECRET_NAME> with the actual secret name and <KEY> with the specific key you need.

kubectl get secret <SECRET_NAME> -o jsonpath='{.data.<KEY>}'
3

Decode the base64 encoded secret. Replace <ENCODED_SECRET> with the encoded value from step 2.

echo '<ENCODED_SECRET>' | base64 --decode