(Kubernetes pod to local 파일 복사 / Kubernetes container to local)
그런데 K8S 버그?로 에러메시지가 게속 떠서 안 되고 있는 줄 알았는데,
잘 되고 있더라!!! ㅎㅎ 그래도 나처럼 또 헤매고 있을 누군가에게 도움이 되기 위해!
우선, kubectl cp -h 라고 치면 다음과 같이 나온다.
$ kubectl cp -h
# !!!Important Note!!!
# Requires that the 'tar' binary is present in your container
# image. If 'tar' is not present, 'kubectl cp' will fail.
# 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/bar in a remote pod in namespace <some-namespace>
kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar
# Copy /tmp/foo from a remote pod to /tmp/bar locally
kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar