Skip to content

Instantly share code, notes, and snippets.

@aslafy-z
Created August 27, 2021 10:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aslafy-z/70c9a3099e71d0173b52790fccbb3e89 to your computer and use it in GitHub Desktop.
Save aslafy-z/70c9a3099e71d0173b52790fccbb3e89 to your computer and use it in GitHub Desktop.
kube-clear-secret - Convert a Kubernetes secret to its stringData clear form.

kube-clear-secret

This tool takes a secret in the JSON format in STDIN and outputs the same secret with the data field replaced with a clear-text stringData. This allows to make patches to secrets from clear-text like the following:

kubectl get secret my-secret -ojson | kube-clear-secret | sed 's/my-old-value/my-new-value/g' | kubectl apply -f -
#!/bin/sh
jq '.stringData = (.data | to_entries | map(. + {"value": .value | @base64d }) | from_entries) | del(.data)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment