Copy file to and from Matlab pod

379

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 Windows Power 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 that your pod is in running status or not. Also, you need to compress a folder using 7zip in tar format. Download 7zip software and create a tar file of local folder you want to copy to kubernetes container pod.
First, you need to check your pod is active or not. Open Windows Powershell and check the status of your pod using kubectl command.

#Command sample
kubectl describe pod podname

In our case the pod name is sumit49670231-matlab so the command is

kubectl describe pod sumit49670231-matlab

Below is the output of the command

Know status of your pod
Know status of your pod

Using 7zip software compress the folder to the tar format you want to copy.  Now, we are ready to proceed, and we will try 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 “C:\Users\sumrak\Downloads\images”. 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 sumit49670231-matlab:/home/vscode/workspace/data

 

Kubectl copy from 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 sumit49670231-matlab:/home/vscode/workspace/data/images.tar .\images.tar

 

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