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?
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
kubectl 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
Check out this article.
In short, this is the command:
kubectl exec pod-01 -- tar cf - /dir1 /dir2 | kubectl exec -i pod-02 -- tar xvf - -C /
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With