What could be the kubectl
command to see k8s
secret
values
I tried
kubectl get secrets/<secrets-name> -n <namespace>
It returns
NAME TYPE DATA AGE secrets1 Opaque 1 18h
but I want to know what value stored inside the secret
What could be the kubectl
command to see k8s
secret
values
I tried
kubectl get secrets/<secrets-name> -n <namespace>
It returns
NAME TYPE DATA AGE secrets1 Opaque 1 18h
but I want to know what value stored inside the secret
Say you had a secret like the one below with a password key then something like this should work to obtain the value:
kubectl get secret/my-secret -n dev -o go-template='{{.data.password|base64decode}}'
apiVersion: v1
kind: Secret
metadata:
name: my-secret
namespace: dev
type: Opaque
data:
password: TXEyRCMoOGdmMDk=
username: cm9vdA==
So the answer was so simple I just have to add -o jsonpath='{.data}'
at the end of the command
kubectl get secrets/<secrets-name> -n <namespace> -o jsonpath='{.data}'