想从k8s的pod中拷贝文件到宿主机,kubectl 的cp命令,但是网上搜索了下,感觉有点乱,自己记录下。

    hadoop这个namespace下,有个hadoop-hadoop-yarn-rm-0的pod,它的work_dir是/usr/local/hadoop,在这个目录下有个application_1564318400358_0562_1文件,现在的目的是将此文件拷贝到宿主机上,命令如下List-1所示。由于我们的work_dir是/usr/local/hadoop,所以不需要写完全路径/usr/local/hadoop/application_1564318400358_0562_1,写完全路径反而会报错

    List-1

kubectl cp -n hadoop hadoop-hadoop-yarn-rm-0:application_1564318400358_0562_1 ./

    如下List-2中报错

    List-2

[~]$ kubectl cp -n hadoop hadoop-hadoop-yarn-rm-0:/usr/local/hadoop/application_1564318400358_0562_1 ./
tar: Removing leading `/' from member names
[~]$ kubectl cp -n hadoop hadoop-hadoop-yarn-rm-0:usr/local/hadoop/application_1564318400358_0562_1 ./
error: usr/local/hadoop/application_1564318400358_0562_1 no such file or directory

 

转载于:https://my.oschina.net/u/2518341/blog/3081584

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐