Skip to content

Instantly share code, notes, and snippets.

@skuethe
Created November 6, 2020 12:19
Show Gist options
  • Save skuethe/e7c0e3db53cdac06756a3abaeba155a1 to your computer and use it in GitHub Desktop.
Save skuethe/e7c0e3db53cdac06756a3abaeba155a1 to your computer and use it in GitHub Desktop.
bash alias for easily decrypting helm3 release secrets
helmsecret() {
local fetchSecretJson
local doesSecretExist
if [[ -z "${1}" ]]; then
echo "Missing secret name. Terminating"
exit 1
else
if [[ "${1}" == *"sh.helm.release"* ]]; then
fetchSecretJson=$(kubectl get secret --ignore-not-found --all-namespaces --output json --field-selector "metadata.name=${1}")
doesSecretExist=$(echo "${fetchSecretJson}" | jq --raw-output 'if (.items | length) > 0 then "true" else empty end')
if [[ "${doesSecretExist}" == "true" ]]; then
echo "${fetchSecretJson}" | jq --raw-output '.items[0].data.release' | base64 -d | base64 -d | gzip -d
else
echo "There is no such helm secret on this cluster"
fi
else
echo "This is not a helm secret :("
fi
fi
}
@skuethe
Copy link
Author

skuethe commented Nov 6, 2020

example usage:

helmsecret sh.helm.release.v1.SOMERELEASE.v2 | less

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment