How To See Kubernetes Secret Data?
Kubernetes secrets are data in key-value format stored secretly for your applications deployed in a Kubernetes system. If you have proper rights and, for debugging purposes you wish to see the secret data then this post will help you.
To see Kubernetes secret data you must have proper rights to see its pods/deployments/secrets. This post assumes you have basic knowledge of Kubernetes and understand how to get access to a Kubernetes instance and you can run commands like kubectl get pod/deployments/secrets successfully.
Steps involved:
1. Get Kubernetes secret in details
2. Decode the secret data
Get Kubernetes Secret in Detail
You can normally get any resource list in Kubernetes by command 'kubectl get pods/deployments/secrets'. Similarly `secret` is also a resource. You get secret list by command:
>> kubectl get secrets
NAME TYPE DATA AGE
default-token-kctfm kubernetes.io/service-account-token 3 634d
test-secret Opaque 1 258d
It will list all the secrets for the Kubernetes instance. Now choose the secret name of which you wish to see the data. Let's say in our case it's 'test-secret'.
To get the secret data in detail, run the following command:
The output will be in YAML file format. Notice your keys and its respective values of secrets will be under 'data' attribute i.e., testKey: dGVzdEtleURhdGEK. The value is actually base64 encoded.
Decode the Kubernetes Secret Data
To decode your key's value, either you can Google "decode base64 online". But if your secret is a corporate secret better avoid it. Make sure you have a Linux terminal open and run the following command:
For our case it will be:
TADDDDAAAAAAAaaaaaaa your unlocked your secret data stored in your Kubernetes secret vault.
Comments
Post a Comment
Feel free to ask, comment and/or suggest.