2

I was wondering if Docker Swarm was possible to be a load balancer with GlusterFS as the local filesystem? And use Pacemaker to hold the VIP (because I understand Docker cannot create a VIP).

My idea - which I'm hoping can be verified or suggested better :)

System:

2x CentOS 8 servers
- 192.168.0.1
---- /dev/sda (OS)
---- /dev/sdb (data)
- 192.168.0.2
---- /dev/sda (OS)
---- /dev/sdb (data)
  1. Install Pacemaker, Corosync

    dnf --enablerepo=HighAvailability -y install pacemaker pcs psmisc policycoreutils-python-utils
    systemctl start pcsd
    
  2. Add a VIP to both servers

     pcs resource create vip IPaddr2 ip=192.168.0.100 cidr_netmask=24 op monitor interval=30s
    
  3. Set up both storage

     mkfs.xfs /dev/sdb
    
  4. Make the directory and add to startup

     mkdir -p /my-data/
    
     echo "/dev/sdb /my-data xfs defaults 0 0" >> /etc/fstab
    
  5. Install GlusterFS on both nodes

     dnf install -y glusterfs-server
    
  6. Setup Gluster for the volume

     gluster volume create gfs replica 2 transport tcp node01:/my-data node02:/my-data force
     gluster volume start gfs
    
  7. Make it accessible for the replication

     echo 'node01:/my-data /mnt glusterfs defaults,_netdev 0 0' >> /etc/fstab
    
     echo 'node02:/my-data /mnt glusterfs defaults,_netdev 0 0' >> /etc/fstab
    
  8. Install Docker and Docker-Compose

  9. Initialise Swarm

     - on node01 use IP 192.168.0.1 -> manager
     - on node02 use IP 192.168.0.2 -> manager
    
  10. Create the directories

     mkdir /mnt/html
     mkdir /mnt/mysql
    
  11. In the docker-compose.yml file:

    volumes:
        - "/mnt/html:/var/www/html/wp-content"
    volumes:
        - "/mnt/mysql:/var/lib/mysql"
    
  12. Apart of the docker-compose.yml - apache:

    Use IP 192.168.0.100 as the access on 80
    

My thoughts are that as 192.168.0.100 is only accessible on one of the Pacemaker resources, that the secondary Manager wouldn't be hit on the front end. If that node went down on the IP .100 then the other node02 would take that IP and the Swarm would still be active.

Is this something that would work? I cant find anything about having a VIP on the Swarm - at least working solutions.

I have them both as Managers because I assume if the manager goes off then its not going to work? Then if I had a 3rd, 4th, etc. I'd add them as Workers.

markb
  • 1,100
  • 1
  • 15
  • 40

0 Answers0