Skip to content

Instantly share code, notes, and snippets.

@danrigsby
Created December 12, 2017 14:34
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save danrigsby/8346b842d1446628de5223b600668dca to your computer and use it in GitHub Desktop.
Save danrigsby/8346b842d1446628de5223b600668dca to your computer and use it in GitHub Desktop.
Copy kubernetes secrets between namespaces
kubectl get secrets -o json --namespace old | jq '.items[].metadata.namespace = "new"' | kubectl create -f -
@chancez
Copy link

chancez commented Jan 7, 2019

TIL jq let's you access items in a list like .items[].foo, that's super useful. You can actually do the following then:

kubectl get secrets -o json --namespace old | jq 'del(.items[].metadata.namespace)' | kubectl create -f --namespace new

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