Skip to content

Commit

Permalink
new script to extract secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed May 21, 2024
1 parent c6ebe07 commit f33b3d1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions kubernetes/cmsweb/scripts/extract_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
if [ $# -ne 3 ]; then
echo "Extracts all secret files for given namespace and secret into provided output directory"
echo "Usage: extract_secrets.sh <namespace> <secret> <output directory>"
exit 1
fi

ns=$1
secret=$2
odir=$3
files=`kubectl describe secrets -n $1 $2 | grep bytes | awk '{print $1}' | sed -e "s/://g"`
for sfile in $files; do
echo "extract $sfile"
kubectl get secrets -n $ns $secret -o yaml | grep $sfile | head -1 | awk '{print $2}' | base64 -d > $odir/$sfile
done

0 comments on commit f33b3d1

Please sign in to comment.