kubectl cp 在节点 运行 nvidia-docker 上失败并显示 "tar: this does not look like a tar archive"

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

我正在尝试将本地 Python 文件复制到 Kubernetes 上的 运行ning 容器,但失败了:

$ 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

我知道 tar 二进制文件必须在容器中可用,确实如此。

有谁知道这里发生了什么以及我该如何解决这个问题?

更新:

经过更多测试后,我可以确认这只发生在 运行 nvidia-docker 的节点上,而不是正常的 docker。在这些节点上将内容通过管道传输到 kubectl exec 时,流始终为空。

因此,以下命令在启用 GPU 的节点上的 pod 运行ning 中生成一个空文件,而该文件在没有 GPU 支持的其他节点上是非空的:

cat nonempty_file.txt | kubectl exec -i pod -- tee /home/jovyan/empty_file.txt 

这已经在两个节点上使用完全相同的 image/container 进行了测试。

请查看文档:

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

  • 其他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.

请尝试安装合适的 kubectl 版本。

希望对您有所帮助

问题已通过更新 EKS AMI 版本解决。

请安装新版本:eks-ami-releases

参见:eks-ami-kubectl