Skip to content

Instantly share code, notes, and snippets.

@estahn
Last active August 15, 2023 07:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save estahn/6b8cfac387ffacc8738cbe2ffb675932 to your computer and use it in GitHub Desktop.
Save estahn/6b8cfac387ffacc8738cbe2ffb675932 to your computer and use it in GitHub Desktop.
Simple shell function to read out Kubernetes secret in plain text
function kubectl-secrets () {
kubectl get secrets $@ -ojson | jq '{name: .metadata.name, data: .data | map_values(@base64d)}'
}

Pop the function into your file where you keep your shell functions. Then run source <shell function file> to reload it into the shell.

Now you're all set:

$ kubectl-secrets -n foobar secret-sauce
{
  "name": "secret-sauce",
  "data": {
    "ADMIN_PASSWORD": "53O...vg==",
    "ADMIN_USERNAME": "admin"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment