I am working with IBM Kubernetes Service and need to create a directory in the PVC. There are 2 PVCs which are already created. Can I use the same to create a directory or shall I create a new one as those two are already bound?
Also, I tried creating new PV using a PV yaml file, but it is getting killed as soon as I try to create it. Then, I tried creating a PVC directly that refers to the storage class we have. But, the same is happening here as well. Can this be because of some access issue with NFS or what else might be the reason?
Once the directory is created, I also need to push files into it. Need some help with that as well.
A PVC is a linkage between a volume (usually on a Block or NFS device) and your Kubernetes pod. Typically, when you bind a PVC to the pod, you mount it on a specific path within a container in the pod.
So, if you bound a PVC and mounted it to your container at
/foo
, then you should be able to write files directly into that folder. For example, if you were running a bash script, you couldecho "this is some text" > /foo/test.txt
and the text "this is some text" should end up in a file calledtest.txt
within the/foo
folder. Because that's pointing at your external storage volume via the PVC, the data would persist to that location.Remember though, block devices are generally only allowed to mount to a single pod, so if you were running three instances of your deployment, then you'd be reading and writing from three separate storage locations.
One way to work around this limitation is to use NFS (File) storage, but this will likely result in poor performance if you are reading and writing heavily. If you find yourself doing this, then file storage is probably not what you want and you should explore databases or object stores instead.