<p>Using Google Cloud &amp; Kubernetes engine:</p>

<p>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.</p>

<p>Maybe using something like <a href="https://osxfuse.github.io/" rel="nofollow noreferrer">FUSE</a> and in my case osxfuse.</p>

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

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

<p>But I get <code>cd: pods: Permission denied</code></p>

Chris G.
<p>Regarding sharing <code>PersistnetDisk</code> between other <code>VM's</code> it was discussed <a href="https://stackoverflow.com/questions/26910960/share-a-persistent-disk-between-google-compute-engine-vms">here</a>. If you want to use the same PD on many nodes, it would work only in <code>read-only</code> mode.</p>

<p>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</p>

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

<p>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 <code>kubectl get pv</code>. </p>

<pre><code>$ 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
</code></pre>

<p>Enter to it using cd</p>

<pre><code>$ cd &lt;pvc_name&gt;
</code></pre>

<p>in my case:</p>

<pre><code>$ cd gke-gke-metrics-d24588-pvc-53091548-57af-11ea-a629-42010a840131
</code></pre>

<p>now you can list all files inside this PersistentDisk</p>

<pre><code>...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
</code></pre>

<p>There is tutorial on <a href="https://gist.github.com/mollymerp/26ef43f8f72577e7133c95f9c9f893c8" rel="nofollow noreferrer">Github</a> where user used <code>sshfs</code> but on MacOS. </p>

<p>===</p>

<p>Alternative way to mount PD to your local machine is to use <a href="https://kubernetes.io/docs/concepts/storage/volumes/#nfs" rel="nofollow noreferrer">NFS</a>. However, you would need to configure it. Later you could specify mount in your <code>Deployment</code> and your local machine. 
More details can be found <a href="https://github.com/kubernetes/examples/tree/master/staging/volumes/nfs" rel="nofollow noreferrer">here</a>.</p>

<p>===</p>

<p>To create backup's you can consider <a href="https://cloud.google.com/compute/docs/disks/create-snapshots" rel="nofollow noreferrer">Persistent disk snapshots</a>.</p>
