Does kubectl provide a way to copy files from pod in one namespace to another? I see we can copy files from pod to local machine and then copy them on another pod of different namespace. But can we copy directly from one namespace to another?
I tried:
kubectl cp <namespace1>/<pod1>:/tmp/foo.txt <namespace2>/<pod1>:/tmp/foo.txt
Looking at kubectl cp
command help options I don't think there is any way to do that.
Not really kubectl cp
can only copy remote/local or local/remote, so unfortunately it's a 2 step process:
$ kubectl cp <namespace1>/<pod1>:/tmp/foo.txt foo.txt
$ kubectl cp foo.txt <namespace2>/<pod1>:/tmp/foo.txt
I would be nice to have a 1 step process, like rsync, but it is what it is as of this writing. I opened this issue to track it.