How to Implement Your Distributed Filesystem With GlusterFS And Kubernetes

Learn the advantages of using GlusterFS and how can it help in achieving a highly-scalable, distributed filesystem

Timothy Yalugin
Nov 18 · 10 min read
Image for post
Image for post
Photo by Teng Yuhong on Unsplash

Introduction

Image for post
Image for post
GlusterFS old & new logos

Digging Into Architecture

The Instruction

Accessing the Node’s Ground Operating System

Image for post
Image for post
Acquiring droplet access procedure — Illustration by author

Creating a Brand-New Disk Partition

$ apt-get install grml-rescueboot
$ cd /boot/grml$ wget http://download.grml.org/grml64-small_2020.06.iso$ update-grub
$ lsblkNAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
vda 254:0 0 80G 0 disk
├─vda1 254:1 0 79.9G 0 part /
└─vda2 254:2 0 2M 0 part
vdb 254:16 0 446K 0 disk
$ fsck.ext4 -f /dev/vda1$ resize2fs -M /dev/vda1
$ parted /dev/vda$ resizepart 1 30G # shrink vda1 to 30 Gb$ mkpart gluster 30001 100% # create vda3 where vda1 ends$ set 3 lvm on # optionally setup logical volumes$ print # verify results$ quit
$ fdisk -l /dev/vdaDevice      Start    End        Sectors   Size  Type       
/dev/vda1 6144 62920671 62914528 50G Linux filesystem /dev/vda2 2048 6143 4096 2M BIOS boot
/dev/vda3 62920672 1667770111 104857546 30G Linux filesystem

Linking the Storage Device Via a Symlink

$ ls -altr /dev/disk/* | grep <device>
$ udevadm info --root --name=/dev/vda3P: /devices/pci0000:00/0000:00:06.0/virtio3/block/vda/vda3
N: vda3
E: DEVNAME=/dev/vda3
E: DEVPATH=/devices/pci0000:00/0000:00:06.0/virtio3/block/vda/vda3
E: DEVTYPE=partition
E: MAJOR=254
E: MINOR=3
E: SUBSYSTEM=block
E: TAGS=:systemd:
E: USEC_INITIALIZED=1942797
...
ENV{DEVTYPE}=="partition", ENV{SUBSYSTEM}=="block", ENV{DEVPATH}=="/devices/pci0000:00/0000:00:06.0/virtio3/block/vda/vda3" SYMLINK+="disk/gluster-disk"
$ nano /lib/udev/rules.d/10-custom-icp.rules
$ udevadm control --reload-rules
$ udevadm trigger --type=devices --action=change
$ ls -ltr /dev/disk/gluster-*lrwxrwxrwx 1 root root 7 Oct 21 16:20 /dev/disk/gluster-disk -> ../vda3

Setting Up Gluster Client

$ modprobe dm_thin_pool$ echo dm_thin_pool | tee -a /etc/modulesdm_thin_pool # verify output
$ wget -O - https://download.gluster.org/pub/gluster/glusterfs/7/rsa.pub | apt-key add - # install certificate
$ echo deb [arch=amd64] https://download.gluster.org/pub/gluster/glusterfs/7/7.1/Debian/buster/amd64/apt buster main > /etc/apt/sources.list.d/gluster.list
$ apt-get update$ apt-get install glusterfs-client$ /usr/sbin/glusterfs --versionglusterfs 7.1

Deploying Gluster Server and Heketi API

Storage cluster topology example config for Heketi API
$ kubectl get nodes -o wideNAME                  STATUS   AGE   VERSION   INTERNAL-IP kicksware-k8s-3pkt4   Ready    38h   v1.18.8   10.114.0.5    kicksware-k8s-3pkt8   Ready    38h   v1.18.8   10.114.0.3    kicksware-k8s-3pktw   Ready    38h   v1.18.8   10.114.0.4
$ kubectl get services -lrelease=<RELEASE_NAME>NAME             TYPE        CLUSTER-IP       PORT(S)    AGE
gluster-heketi ClusterIP 10.245.189.193 8080/TCP 1m
GlusterFS PersistentVolumeClaim example config
Unable to create node: New Node doesn't have glusterd running

Final Thoughts

Better Programming

Advice for programmers.

Thanks to Zack Shapiro

Timothy Yalugin

Written by

Technology Enthusiast | Software Developer | Distributed Systems Engineer | Prince of the Dark Theme | Sneakerhead | github.com/timoth-y

Better Programming

Advice for programmers.

Timothy Yalugin

Written by

Technology Enthusiast | Software Developer | Distributed Systems Engineer | Prince of the Dark Theme | Sneakerhead | github.com/timoth-y

Better Programming

Advice for programmers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store