Skip to content

Instantly share code, notes, and snippets.

@Tirael
Forked from andor-pierdelacabeza/secretdump.sh
Created August 1, 2022 10:12
Show Gist options
  • Save Tirael/032e7276f4ddc946ad1dfe92e8623642 to your computer and use it in GitHub Desktop.
Save Tirael/032e7276f4ddc946ad1dfe92e8623642 to your computer and use it in GitHub Desktop.
Kubernetes: dump all keys in secret to files:
# Requirements: kubectl and yq ( https://github.com/kislyuk/yq )
# This will take every key/value in a secret, base64 decode the value, and dump the result to
# a file named as the key name
SECRET=credentials-staging NAMESPACE=staging
for i in `kubectl -n ${NAMESPACE} get secret ${SECRET} -o yaml --export|yq -r '.data | keys[]'`
do
echo "Dumping ${i}"
kubectl -n ${NAMESPACE} get secret ${SECRET} -o yaml --export|yq -r '.data."'${i}'"' | base64 -d > ${i}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment