Skip to content

Instantly share code, notes, and snippets.

@scyto
Last active February 24, 2025 09:58
Show Gist options
  • Save scyto/7e9d471c70f92c8b983f38cdc838998d to your computer and use it in GitHub Desktop.
Save scyto/7e9d471c70f92c8b983f38cdc838998d to your computer and use it in GitHub Desktop.
installing a glusterfs volume plugin

Description

I wanted a simpler way to assign gluster volumes in new stacks without having to create directories by hand There are variety of community plugins for this.

I chose to use this one https://github.com/chrisbecke/glusterfs-volume It creates a directory called <stackname>_<volumename> for each volume defined in the stack.

Pre-reqs

Assume you setup glusterfs per this gist here

In my enviroment this is the command I used to install the plugin.

sudo docker plugin install --alias gluster-vol1 chrisbecke/glusterfs-volume GFS_VOLUME=gluster-vol1 GFS_SERVERS=docker01.mydomain.com,docker02.mydomain.com,docker03.mydomain.com

followed by

sudo docker plugin enable gluster-vol1

Example

Now when a volume needed it can be specified as follows and created on the fly.
This example is from adguard.

  1. there are two directories needed, one for work and one for conf.
  2. these are defined at runtime by the \volumes lines after the services section
  3. in the service section these volume are called and mapped in the normal way
version: '3.2'
services:
  adguard1:
    image: 'adguard/adguardhome:latest'
    restart: always
    volumes:
      - work:/opt/adguardhome/work
      - config:/opt/adguardhome/conf
    networks:
      - adguard1

volumes:
  work:
    driver: gluster-vol1
  config:
    driver: gluster-vol1

networks:
   adguard1:
     external: true

Note

The plugin driver can't be used for a file only a directory, if you need a file you can either use docker configs or you can create the file manually in you glusterfs directory and map in as normal

In the example above it would create in my configuration \mount\glustervol\adguard_config and \mount\glustervol\adguard_work and these would be mapped into the container

@EpicShiield
Copy link

Hi, i've an error in this step when i try to install the docker plugins :

ubuntu@swarm1:/srv/docker$ sudo docker plugin install --alias gluster-vol1 chrisbecke/glusterfs-volume GFS_VOLUME=gluster-vol1 GFS_SERVERS=10.10.1.36,10.10.1.104,10.10.1.29
Plugin "chrisbecke/glusterfs-volume" is requesting the following privileges:
 - network: [host]
 - device: [/dev/fuse]
 - capabilities: [CAP_SYS_ADMIN]
Do you grant the above permissions? [y/N] y
latest: Pulling from chrisbecke/glusterfs-volume
Digest: sha256:361edfad6c088e9a5568efb1fee716ca9a571609f8450d8c93210fb6d7747e3e
271356e1c9fe: Complete 
Error response from daemon: dial unix /run/docker/plugins/cb98509651b4bc2f42e5de72f0d17bdbe9b638629fcd085a780bfd9fcfa10faa/glusterfs.sock: connect: no such file or directory

Anyone have any idea ?

@scyto
Copy link
Author

scyto commented Nov 14, 2024

Hi, i've an error in this step when i try to install the docker plugins :

i have seen this when there dns / name resolution / network issues

just keep doing the enable command on all nodes, it will eventually converge, if not look at you hosts files / dns and make sure all nodes can be found by name not just ip

it may also mean your gluster service is not running correctly (the plugin cant access the process socket)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment