Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy files from pod in one namespace to pod in another namespace

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.

like image 363
codec Avatar asked Oct 30 '18 18:10

codec


1 Answers

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.

like image 96
Rico Avatar answered Sep 25 '22 00:09

Rico