Is it possible to know the progress of file transfer with kubectl cp
for Google Cloud?
The kubectl cp command lets you copy files between Kubernetes Pods and your machine. It works in either direction but can't be used to move files from Pod to Pod. If you need to do that, it's best to use a two-stage procedure, copying first from Pod A to your machine, then onward to Pod B.
it will only override the destination different_file.
Kubernetes “kubectl cp” Command to Jeopardize Cloud-Based Host Instances. A high severity security issue was recently found with the K8s kubectl cp command that could possibly allow a directory traversal to delete or replace files on a user's workstation or cloud instance.
No, this doesn't appear to be possible.
kubectl cp
appears to be implemented by doing the equivalent of
kubectl exec podname -c containername \ tar cf - /whatever/path \ | tar xf -
This means two things:
tar(1) doesn't print any useful progress information. (You could in principle add a v
flag to print out each file name as it goes by to stderr, but that won't tell you how many files in total there are or how large they are.) So kubectl cp
as implemented doesn't have any way to get this out.
There's not a richer native Kubernetes API to copy files.
If moving files in and out of containers is a key use case for you, it will probably be easier to build, test, and run by adding a simple HTTP service. You can then rely on things like the HTTP Content-Length:
header for progress metering.
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