Last active
June 10, 2020 17:25
-
-
Save kieranajp/139713043a66af008ef777658e536226 to your computer and use it in GitHub Desktop.
An easy way to look at multiple data items in a Kubernetes secret.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function usage { | |
echo "An easy way to look at multiple data items in a Kubernetes secret." | |
echo " Usage: $(basename $0) <secret> <data ...>" | |
exit 1 | |
} | |
if [[ $# -eq 0 ]] ; then | |
usage | |
fi | |
set -eu | |
name=$1 | |
shift; | |
cmd="kubectl get secret $name -o custom-columns=" | |
for arg | |
do | |
cmd+="$arg:.data.$arg," | |
done | |
secrets=`${cmd%?}` | |
echo "$secrets" | awk 'FNR==2 {print}' | tr -s ' ' '\n' | xargs -I % sh -c 'echo % | base64 -d; echo' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a quick way to grab secrets from Kubernetes, without running
kubectl get secret...
and base64 decoding each manually.Usage: