Kubernetes Admin Toolbox

My k8s Admin Toolbox
Just a set of tools that use while managing my k8s clusters. If you use something different, great, leave a message below.
Scripts
Get Secrets#! /bin/bash
# Call with no params: get list of all secrets
# Call with param secret_name: show keys and decoded contents of that specific secret
# Call with params secret_name key_name: show decoded content of that specific key in that specific secret
if [ $# -eq 0 ]; then
kubectl get secret;
elif [ $# -eq 1 ]; then
if [ "$1" = "-h" -o "$1" = "--help" -o $# -gt 3 ]; then
echo "$0 {secret} [key]";
else
kubectl get secret $1 -o yaml |
sed -n '/^data:/,/^kind:/p' | sed '1d;$d' |
(IFS=":"; while read key val; do echo -n "${key}: "; $0 $1 $key; done);
fi
elif [ $# -eq 2 ]; then
SECRET="$1"; KEY="$2";
kubectl get secret ${SECRET} -o yaml | grep ${KEY}: | awk '{ print $2 }' | base64 --decode ; echo "" ;
fi;
Aliases
Here is my ~/.bash_profile
alias k="kubectl"
## Add the get_secret.sh from the scripts section
alias gs=~/scripts/get_secret.sh
3rd Party
kube-ps1https://github.com/jonmosco/kube-ps1
Adds the current cluster/context to you shell prompt