1

Using Google Cloud & Kubernetes engine:

Is there a smart way to view or mount a PersistentVolume(physical Storage, in the case of Google PD) to a local drive/remote computer/macos, or anything able to view data on the volume - to be able to backup or just view files.

Maybe using something like FUSE and in my case osxfuse.

Obviously I can mount a container and exec, but maybe there are other ways?

Tried to ssh into the node and cd to /home/kubernetes/containerized_mounter/rootfs/var/lib/kubelet

But I get cd: pods: Permission denied

Chris G.
  • 23,930
  • 48
  • 177
  • 302
  • 1
    What do you mean by local drive? Linux can mount a PV to a mount point. The issue is the PV volume disk format that and this will determine if you can read the data as directories/files. Edit your question with more details on your exact environment. Docker volumes are files combined using the Union FS. These files are viewable in the host OS. I am not aware of a Docker/Container tool that will take a GCP PV, mount it and process the contents. – John Hanley Feb 19 '20 at 16:41
  • anything able to view data on the volume - to be able to backup or just view files – Chris G. Feb 19 '20 at 17:20
  • 1
    Not sure if I good understood you. Could you elaborate? Also did you saw this: https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/local-ssd ? – PjoterS Feb 20 '20 at 11:33
  • Thanks, I am just looking for a way to see files in a PV from a local machine. – Chris G. Feb 20 '20 at 11:41

1 Answers1

1

Regarding sharing PersistnetDisk between other VM's it was discussed here. If you want to use the same PD on many nodes, it would work only in read-only mode.

Easiest way to check what's inside the PD is to SSH to node (like you mentioned), but it will require superuser privileges (sudo) rights. - SSH to node

$ sudo su
$ cd /home/kubernetes/containerized_mounter/rootfs/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts
$ ls 

Now you will get a few records, depends on how many PVC you have. Name of folder is the same as name you get from kubectl get pv.

$ kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                  STORAGECLASS   REASON   AGE
pvc-53091548-57af-11ea-a629-42010a840131   1Gi        RWO            Delete           Bound       default/pvc-postgres   standard                42m

Enter to it using cd

$ cd <pvc_name>

in my case:

$ cd gke-gke-metrics-d24588-pvc-53091548-57af-11ea-a629-42010a840131

now you can list all files inside this PersistentDisk

...gke-gke-metrics-d24588-pvc-53091548-57af-11ea-a629-42010a840131 # ls
lost+found  text.txt
$ cat text.txt 
This is test
It's not empty

There is tutorial on Github where user used sshfs but on MacOS.

===

Alternative way to mount PD to your local machine is to use NFS. However, you would need to configure it. Later you could specify mount in your Deployment and your local machine. More details can be found here.

===

To create backup's you can consider Persistent disk snapshots.

PjoterS
  • 12,841
  • 1
  • 22
  • 54