'Download directory from Pod to local using Python kubernetes client

I have been able to download a file from Pod to local using the Python Kube client. The code is available here. However, I don't see any example to download directory from pod to local in the official examples. As a workaround, I am creating a tar file of the directory in the pod. Then I am downloading the tar of the directory as a file to local and extract it.

directory -> tar -> download tar -> extract tar at local -> delete tar in pod -> delete tar in local

However, this approach involves clean-up of the temporary tar in the pod as well as local and is not very clean. Is there any better way to download the whole directory from pod to local?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source