Do you know? Well, before today, neither did I.
I’m pretty late to Kubernetes. I heard about it many hears ago, but unfortunately, I had no need to use it at home or at work. Even today, there is no workload that requires a Kubernetes cluster to run on. However, I think I can’t ignore Kubernetes any longer, and I need to learn about it now, well “better be late than never”, right?
Today, I need to access a persistent volume claim (PVC) so that I can rsync data from a backup to it. The persistent volume (PV) used on my test cluster is Longhorn. Here are the steps performed to achieve such task [^1].
- Go to Longhorn UI, attach the volume to a node. For example
r8s-worker1
. - Connect to
r8s-worker1
node using SSH. Runls -l /dev/longhorn
. You will see the block device with the nameVOLUME-NAME
.
[rocky@r8s-worker1 ~]$ ls -l /dev/longhorn/
total 0
brw-rw---- 1 root root 8, 0 Oct 15 07:53 pvc-5242ccd4-5a41-4bb4-b5f8-6f64118f4d33
- Mount the block device to a directory on the
r8s-worker1
withsudo mount /dev/longhorn/<VOLUME-NAME> /mnt/
[rocky@r8s-worker1 ~]$ sudo mount /dev/longhorn/pvc-5242ccd4-5a41-4bb4-b5f8-6f64118f4d33 /mnt
- Now you can access the data at
/mnt
.
[rocky@r8s-worker1 ~]$ ls -l /mnt
total 40
drwxr-xr-x 2 911 911 4096 Oct 14 14:09 keys
drwxr-xr-x 4 911 911 4096 Oct 14 14:09 log
drwx------ 2 root root 16384 Oct 14 14:09 lost+found
drwxrwxr-x 3 911 911 4096 Oct 15 07:25 nginx
drwxr-xr-x 2 911 911 4096 Oct 14 14:09 php
drwxr-xr-x 2 911 911 4096 Oct 14 14:09 www
Full credit goes to [^1].