How do I view the value of a secret via kubectl?

1/10/2019

Is there a way I can view the secret via kubectl?

Given the secret name, and the data (file?) how do I view the raw result?

-- Chris Stryczynski
kubectl
kubernetes

1 Answer

1/10/2019

The following solution relies on jq.

secretName="example-secret-name" secKeyName="example.key"
kubectl get secret "$secretName" -o json | jq -r ".[\"data\"][\"$secKeyName\"]" | base64 -d
-- Chris Stryczynski
Source: StackOverflow