Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Openshift Container Storage - copy file to persistent volume

I am trying to copy some files to a persistent volume that will be later on mounted on a pod. In the example I am looking at they use NFS PV and it is quite simple as I can access the NFS file system associated with a PV and I can add files to it. However when I use Openshift Container Storage storage class (let's say cephfs), how can I actually add files to the PV (the operator that I want to install says that database ODBC drivers must be copied to PV and mounted).

Thanks.

like image 937
Atanas Matev Avatar asked Sep 07 '25 22:09

Atanas Matev


2 Answers

Mount the PV in a different pod, and "oc cp" the files in, or "oc rsh ..." and curl/wget/scp from inside the pod to the local volume mount.

On an existing pod, you can also create a sidecar container with, e.g, busybox to mount the same PV and provide file copy tools if they're not present in the primary container.

like image 199
dbaker Avatar answered Sep 11 '25 02:09

dbaker


you can use the below command to copy files from local to ocp PV.

oc cp <source_path> <env_name>/<pod_name>:/<folder_name>/<sample_file>.<extension>

example : move to the folder from which you want to copy the file. let's say you have a test folder in which you have test.json that you want to copy so here would be the command.

cd test

oc cp . env1/pod1:/cepfs/test.json

like image 36
Prashant Kanak Avatar answered Sep 11 '25 00:09

Prashant Kanak