Created
November 6, 2020 12:19
-
-
Save skuethe/e7c0e3db53cdac06756a3abaeba155a1 to your computer and use it in GitHub Desktop.
bash alias for easily decrypting helm3 release secrets
This file contains hidden or 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
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example usage:
helmsecret sh.helm.release.v1.SOMERELEASE.v2 | less