Skip to content

Instantly share code, notes, and snippets.

@torsak
Created October 22, 2021 09:00
Show Gist options
  • Save torsak/f4ed8c3b9980ecb547952f64773113f1 to your computer and use it in GitHub Desktop.
Save torsak/f4ed8c3b9980ecb547952f64773113f1 to your computer and use it in GitHub Desktop.
k8s reveal secret
#!/bin/bash
if [ $3 ]
then
kubectl get secret/$1 -n $3 -o jsonpath="{.data.$2}" | base64 -d
else
kubectl get secret/$1 -o jsonpath="{.data.$2}" | base64 -d
fi
@torsak
Copy link
Author

torsak commented Oct 22, 2021

  1. chmod +x ksecret.
  2. Put this file in ~/bin.
  3. Update the pathPATH=~/bin:$PATH.

Usage:
ksecret <secret-name> <data-name> <namespace-optional>

Example:
ksecret database-credentials POSTGRES_PASSWORD
or with a specific namespace.
ksecret database-credentials POSTGRES_PASSWORD release

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