diff --git a/keepalived/docker-compose.yml b/keepalived/docker-compose.yml index 41b2c7e..e8efeac 100644 --- a/keepalived/docker-compose.yml +++ b/keepalived/docker-compose.yml @@ -3,15 +3,33 @@ services: image: osixia/keepalived:latest container_name: keepalived restart: unless-stopped - # Must run on host network to manage the interface IP network_mode: host + # Privileged is often required to manipulate Host Network Interfaces + privileged: true + # capabilities are good, but 'privileged' is safer for network manipulation in LXC cap_add: - NET_ADMIN - NET_BROADCAST - NET_RAW + + volumes: + # Inject the check script + - /docker/management/check_komodo.sh:/container/service/keepalived/assets/check_komodo.sh + environment: - - KEEPALIVED_INTERFACE=eth0 # Check if your LXC interface is eth0 + - KEEPALIVED_INTERFACE=eth0 - KEEPALIVED_ROUTER_ID=51 - - KEEPALIVED_VIRTUAL_IPS=172.16.201.2/24 # THE FLOATING IP - - KEEPALIVED_PRIORITY=${KEEPALIVED_PRIORITY} # 150 for Master, 100 for Backup - - KEEPALIVED_PASSWORD=${DNS_ADMIN_PASSWORD} \ No newline at end of file + - KEEPALIVED_VIRTUAL_IPS=172.16.201.250 # Your VIP + - KEEPALIVED_PASSWORD=${DNS_ADMIN_PASSWORD} + + # MASTER/BACKUP Logic (Using Variables) + # On PVE2: Set KEEPALIVED_STATE=MASTER, PRIORITY=101 + # On PVE1: Set KEEPALIVED_STATE=BACKUP, PRIORITY=100 + - KEEPALIVED_STATE=${KEEPALIVED_STATE} + - KEEPALIVED_PRIORITY=${KEEPALIVED_PRIORITY} + + # The Magic Check: Monitors Komodo! + - KEEPALIVED_CHECK_SCRIPT=/container/service/keepalived/assets/check_komodo.sh + - KEEPALIVED_CHECK_INTERVAL=2 + - KEEPALIVED_CHECK_RISE=1 + - KEEPALIVED_CHECK_FALL=2 \ No newline at end of file