🔐 A lightweight CLI utility for decoding and patching Kubernetes secrets.
kubesecrets wraps kubectl to streamline the most common operations you perform with secrets — including base64 decoding and inline patching — while supporting flexible key lookups and safe editing patterns.
- 🔍 Decode secrets cleanly by key or dump them all
- 🛠️ Patch existing keys with new values (stdin, prompt, or CLI arg)
- 🧩 Optional fallback strategies via environment variables
- 🔐 Supports
--kubeconfigfor working with multiple clusters - ✅ Dry-run mode for safety
- 💡 Append mode (
--append) for creating new keys
git clone https://github.com/cclose/kubesecrets.git
cd kubesecrets
chmod +x kubesecrets
./kubesecrets --helpIf you're using the public tap repo for Homebrew:
brew tap cclose/tap
brew install cclose/tap/kubesecretskubesecrets get -n mynamespace -s mysecretOr fetch a specific key:
kubesecrets get -s dockerhub-auth -k passwordkubesecrets patch -s dockerhub-auth -k password -u 'hunter2'Prompt for value:
kubesecrets patch -k password -pRead from stdin:
echo -n 'hunter2' | kubesecrets patch -k password -iAdd a new key (only if it doesn't already exist):
kubesecrets patch -k new-token -u 'foobar' --appendkubectl(connected to your cluster)jqbase64
These can be set to simplify repetitive operations:
-
KUBESECRETS_DEFAULT_SECRET_NAMEUse this if-sis not passed -
KUBESECRETS_NAMESPACE_SECRET_FALLBACK=trueTries using a secret named after the namespace -
KUBESECRETS_NAMESPACE_SECRET_SUFFIX=_conn_infoUsed with fallback to trymynamespace_conn_infoif fallback is enabled
This tool is written entirely in Bash for portability. Tested on macOS and Linux. Feel free to open an issue or PR for enhancements.