Skip to content

Instantly share code, notes, and snippets.

@tatupesonen
Last active April 11, 2023 19:39
Show Gist options
  • Save tatupesonen/80c430ad8c8cd96c45b41d55de1dcd32 to your computer and use it in GitHub Desktop.
Save tatupesonen/80c430ad8c8cd96c45b41d55de1dcd32 to your computer and use it in GitHub Desktop.
Quick bash function to update a Kubernetes secret
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