やりたいこと
podからlocal(host)へファイルをcpしたい。
でてきたエラー、警告
tar: xxx: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
tar: Removing leading `/' from member names
試すこと
絶対パス指定してみる
kubectl cp <pod>:/var/www/html/index.html ./index.html
絶対パス(先頭の"/"なし)にしてみる
kubectl cp <pod>:var/www/html/index.html ./index.html
WORKDIRにファイルを配置して、cpしてみる
ファイルをWORKDIR?(exec -it -- bashで入った時のパスの場所)にファイルを配置して、パスなしのファイル名だけでkubectl cp
操作例
> kubectl exec -it <pod> -- bash
> cp ./dir/other.html ./
> kubectl cp <pod>:other.html ./othe#r.html
参考
[k8s]kubectl copy が「tar: Removing leading `/' from member names」で失敗
kubernetesポッドからローカルシステムにファイルをコピーする方法
Kubectl cp gives "tar: removing leading '/' from member names" warning