Skip to content

Instantly share code, notes, and snippets.

@estahn
Last active August 15, 2023 07:48
Show Gist options
  • 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

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"
  }
}
function kubectl-secrets () {
kubectl get secrets $@ -ojson | jq '{name: .metadata.name, data: .data | map_values(@base64d)}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment