Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we see transfer progress with kubectl cp?

Is it possible to know the progress of file transfer with kubectl cp for Google Cloud?

like image 640
akshitsethi Avatar asked Jan 21 '19 15:01

akshitsethi


People also ask

What does kubectl cp do?

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.

Does kubectl cp overwrite?

it will only override the destination different_file.

Is kubectl cp Secure?

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.


1 Answers

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:

  1. 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.

  2. 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.

like image 161
David Maze Avatar answered Sep 24 '22 06:09

David Maze