Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save simonswine/6bf3b665e4117f42b550c3ea12dd171a to your computer and use it in GitHub Desktop.
Save simonswine/6bf3b665e4117f42b550c3ea12dd171a to your computer and use it in GitHub Desktop.
Copying kubernetes resources accross namespaces
kubectl get rs,secrets -o json --namespace old | jq '.items[].metadata.namespace = "new"' | kubectl create-f -
@jeff1985
Copy link

So what is the alternative to --export ?

@Sureshravi40
Copy link

I wanted too make a copy all my resources running in sandbox namespace to staging namespace , Hence tired running this following cmd

kubectl get rs,secrets -o json --namespace sandbox | jq '.items[].metadata.namespace = "staging"' | kubectl create -f -

A copy of my resources gets created inside staging namespace, all the pods fails with an error:

authorization-55b866f8c4-7nkxp 0/1 CreateContainerConfigError 0 77s
consults-6b796cf5f4-wrjbf 0/1 CreateContainerConfigError 0 77s
core-api-8dd575db9-9bgth 0/1 CreateContainerConfigError 0 77s

what I am doing wrong? I just wanted to make a copy of this resources into staging namespace and play around

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