Last active
April 11, 2023 19:39
-
-
Save tatupesonen/80c430ad8c8cd96c45b41d55de1dcd32 to your computer and use it in GitHub Desktop.
Quick bash function to update 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
update_secret() { | |
# Uses yq and kubectl: | |
# https://mikefarah.gitbook.io/yq/ | |
local SECRET=$(kubectl get secret $1 -o yaml) || echo "error" | |
local YAML=$(echo $SECRET | yq '.data[] |= @base64d') | |
local TMP=$(mktemp /tmp/secret.XXXXXXXXXXX.yaml) | |
echo $YAML > $TMP | |
$EDITOR $TMP | |
cat $TMP | yq '.data[] |= @base64' | kubectl apply -f - | |
rm $TMP | |
} | |
alias s8s=update_secret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment