-
-
Save simonswine/6bf3b665e4117f42b550c3ea12dd171a to your computer and use it in GitHub Desktop.
kubectl get rs,secrets -o json --namespace old | jq '.items[].metadata.namespace = "new"' | kubectl create-f - |
It might be neccessary to delete some metadata in order to apply/create it. I'm not sure which values I had to delete to make it work, but the UUID is probably a good start.
Also consider using the --export
option on get
command:
--export=false: If true, use 'export' for the resources. Exported resources are stripped of cluster-specific information.
Export is now deprecated 😢
The command kubectl get secret www-snowdrop-dev-tls -n snowdrop-site -o yaml | sed 's/namespace: snowdrop-site/namespace: generator-site/' | kubectl create -n generator-site -f -
is failing
for: "STDIN": Operation cannot be fulfilled on secrets "www-snowdrop-dev-tls": the object has been modified; please apply your changes to the latest version and try again
So what is the alternative to --export ?
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
Reads corrected