I'm trying to copy a local Python file to a running container on Kubernetes and it fails:
$ kubectl cp /path/to/file.py namespace/pod:/path/in/container/file.py
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
command terminated with exit code 2
I know the tar
binary must be available in the container, and it is.
Does anyone know what's going on here and how I can solve this?
UPDATE:
After some more testing I can confirm that this only happens on nodes that run nvidia-docker
rather than the normal docker
. When piping things into kubectl exec
on these nodes the stream is always empty.
So the following command yields an empty file in the pod running on a GPU-enabled node while the file is non-empty on other nodes without GPU support:
cat nonempty_file.txt | kubectl exec -i pod -- tee /home/jovyan/empty_file.txt
This has been tested using the exact same image/container on both nodes.
The kubectl cp command is used to copy files between containers and the user machine or cloud instance. To copy files from a container, Kubernetes first creates a tar file inside the container, copies it over the network, and then kubectl unpacks it on the user's machine or cloud instance.
# Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace kubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir # Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container> # Copy /tmp/foo local file to /tmp/ ...
it will only override the destination different_file. txt which is already present in the destination /tmp/test directory.
kubectl will connect to your cluster, run /bin/sh inside the first container within the demo-pod pod, and forward your terminal's input and output streams to the container's process.
Problem is solved by updating EKS AMI version.
Please install new release: eks-ami-releases.
See: eks-ami-kubectl.
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