Docker Swarm
GlusterFS
Install
sudo apt install glusterfs-server sudo systemctl start glusterd.service
Add peer
sudo gluster peer probe docker-pi-b
Create Volume
gluster volume create gv0 replica 2 docker-pi-a:/opt/brick docker-pi-b:/opt/brick gluster volume create gv0 replica 2 docker-pi-a:/opt/brick docker-pi-b:/opt/brick force gluster volume start gv0
Mount volume
mount -t glusterfs docker-pi-a:/gv0 /mnt/gv0/
VRRP
Install keepalived
sudo apt install keepalived
Configure keepalived
cd /etc/keepalived/ sudo joe keepalived.conf
/etc/keepalived/keepalived.conf @ master node
vrrp_instance vrrp_a { interface wlan0 state MASTER virtual_router_id 133 priority 101 authentication { auth_type AH auth_pass pass } virtual_ipaddress { 192.168.38.38 } }
/etc/keepalived/keepalived.conf @ backup node
vrrp_instance vrrp_a { interface wlan0 state BACKUP virtual_router_id 133 priority 100 authentication { auth_type AH auth_pass pass } virtual_ipaddress { 192.168.38.38 } }
Start VRRP:
sudo service keepalived start
Swarm
Install Docker
echo "deb [arch=armhf] https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - sudo apt install --no-install-recommends docker-ce sudo usermod -a -G docker pi
Create Swarm
Node A:
docker swarm init docker swarm join-token manager
Node B:
docker swarm join --token *token* 192.168.38.85:2377
Create stack for Traefik
Node:
docker network create --driver overlay --attachable backend docker network create --ingress --driver overlay pub
docker stack deploy -c traefik.yml traefik
traefik.yml:
version: "3.4" services: traefik: image: traefik:latest command: - "--docker" - "--docker.swarmmode" - "--docker.watch" - "--web" volumes: - type: bind source: /var/run/docker.sock target: /var/run/docker.sock networks: - "backend" ports: - "80:80" - "8080:8080" - "443:443" deploy: replicas: 2 placement: constraints: - node.role == manager restart_policy: condition: on-failure networks: backend: external: true