Operator for keepalived on docker swarm.
Uses osixia/docker-keepalived.
- Enable the "ip_vs" kernel module if not enabled
lsmod | grep -P '^ip_vs\s' || (echo "modprobe ip_vs" >> /etc/modules && modprobe ip_vs)
- Set a different priority for each node
docker node update node1 --label-add KEEPALIVED_PRIORITY=100
docker node update node2 --label-add KEEPALIVED_PRIORITY=200
docker node update node3 --label-add KEEPALIVED_PRIORITY=300
- Deploy the stack
https://hub.docker.com/r/lolhens/keepalived-swarm
version: '3.7'
services:
keepalived:
image: lolhens/keepalived-swarm:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker:ro
networks:
- host
deploy:
mode: global
placement:
constraints: [node.role == manager]
environment:
KEEPALIVED_VIRTUAL_IPS: "192.168.1.231, 192.168.1.232"
networks:
host:
external: true
name: host
- https://github.com/acassen/keepalived
- https://github.com/osixia/docker-keepalived
- https://geek-cookbook.funkypenguin.co.nz/ha-docker-swarm/keepalived/
This project uses the Apache 2.0 License. See the file called LICENSE.