Skip to content

Instantly share code, notes, and snippets.

@ptesny
Forked from welshstew/kube-secret-to-file.sh
Created July 7, 2024 08:40
Show Gist options
  • Select an option

  • Save ptesny/3978b0aa08ce1d472add58a61d825858 to your computer and use it in GitHub Desktop.

Select an option

Save ptesny/3978b0aa08ce1d472add58a61d825858 to your computer and use it in GitHub Desktop.
use jq to pull base 64 things out of a secret and construct them to file
#pull a base64 encoded files out of a kubernetes json secret
oc get secrets/broker-client-secret -o json | jq -r '.data."client.ts"' | base64 -d > client.ts
oc get secrets/broker-server-secret -o json | jq -r '.data."broker.ks"' | base64 -d > broker.ks
oc get secrets/broker-server-secret -o json | jq -r '.data."broker.ts"' | base64 -d > broker.ts
#replace base64 content in a secret - and save to file
THINGY=$(base64 newbroker.ks)
oc get secrets/il3-broker-server-secret -o json | jq -r --arg THINGY $THINGY '.data."broker.ks" = $THINGY' > my-new-secret.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment