Copy files to and from Python pod

620

This is an important step, once you launch your GUI matlab setup, you have to copy your data from your local laptop/Desktop to your Matlab pod. It can be done using Linux bash shell. In this section, we will see how to copy the data from local system to your remote pod and vice-versa.

Things to Check 

Before proceeding, you first need to check whether your pod is in running status or not.
First, you need to check whether your pod is active or not. Open Linux bash shell and check the status of your pod using kubectl command.

#Command sample
kubectl describe pod podname

In our case, the pod name is sumit36718160 so the command is

kubectl describe pod sumit36124091

Below is the output of the command

Know the status of your pod
Know the status of your pod

 

Compress the folder to the tar format you want to copy.  Now, we are ready to proceed, and we will try to copy the tar file to the remote pod.

Copy file from local Laptop/Desktop to Remote Pod

Switch to the folder using Windows Powershell, in this example, the images.tar is placed in the directory “/home/sumit/files”. Switch to the directory.

 

Switch to the directory
Switch to the directory

 

Run the kubectl command in the below format

#Sample format
kubectl cp local_tar_file_path pod_name:directory_path
#Sample Command Example
kubectl cp ./images.tar sumit36124091-pytorch:/home/vscode/workspace/data

 

Kubectl copy local file to Kubernetes container pod
Kubectl copy local file to Kubernetes container pod

 

Note

Always copy the files inside folder /home/vscode, this is where the PVC storage is mounted.

 

Copy data from Remote Pod to local Laptop/Desktop

 

Now, we will copy the file from the remote pod to the local computer.

Run the kubectl command in the below format

#Sample format
kubectl cp pod_name:filepath local_tar_file_path 
#Sample Command Example
kubectl cp sumit36124091-pytorch:home/vscode/workspace/data/images.tar ./images.tar

 

Kubectl copy from Kubernetes container pod to local
Kubectl copy from Kubernetes container pod to local