How can I copy files between pods or between nodes in the kubernetes cluster?

JDev picture JDev · Jul 19, 2018 · Viewed 7.3k times · Source

Is this possible inside the kubernetes cluster?

All examples I've found are copying from a local disk to a pod or vice versa, or is the only option to copy from node to node, for example over SSH, SCP or with other utilities?

Answer

jaxxstorm picture jaxxstorm · Jul 19, 2018

It's not possible to do cluster to cluster copying. You'd need to use kubectl cp to copy it locally, then copy the file back:

kubectl cp <pod>:/tmp/test /tmp/test
kubctl cp /tmp/test <pod>:/tmp/test

If you are trying to share files between pods, and only one pods needs write access, you probably want to mount an ro volume on multiple pods, or use an object store like S3. Copying files to and from pods really shouldn't be something you're doing often, that's an anti-pattern