kubectl cp fails with "tar: this does not look like a tar archive" on nodes running nvidia-docker

10/21/2019

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.

-- Simon G.
amazon-eks
aws-eks
kubectl
kubernetes
nvidia-docker

1 Answer

10/24/2019

Please take a look for the docs:

  • Supported releases and component skew,

    Nodes may lag masters components by up to two minor versions but should be at a version no newer than the master; a client should be skewed no more than one minor version from the master, but may lead the master by up to one minor version. For example, a v1.3 master should work with v1.1, v1.2, and v1.3 nodes, and should work with v1.2, v1.3, and v1.4 clients.

  • other github issues,

  • k8s docs,

kubectl is supported within one minor version (older or newer) of kube-apiserver.

  • v1.16.0 release

    kubectl cp no longer supports copying symbolic links from containers; to support this use case, see kubectl cp --help for examples using tar directly opy files and directories to and from containers.

Examples: # !!!Important Note!!! # Requires that the 'tar' binary is present in your container # image. If 'tar' is not present, 'kubectl cp' will fail.

Please try and install appropriate kubectl version.

Hope this help

-- Hanx
Source: StackOverflow