Skip to content

Instantly share code, notes, and snippets.

@danrigsby
Created December 12, 2017 14:34
  • Star 11 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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