diff --git a/divers/keepalived_on_docker_01.md b/divers/keepalived_on_docker_01.md new file mode 100644 index 0000000..4a7f925 --- /dev/null +++ b/divers/keepalived_on_docker_01.md @@ -0,0 +1,94 @@ + +## DNS enteries: +```text +ivera-db1 IN A 192.168.0.109 +ivera-db2 IN A 192.168.0.110 +ivera-db-vip IN A 192.168.0.115 +``` + + +## Master node + +File `docker-compose.yml`: +```yml +services: + keepalived: + image: osixia/keepalived:latest + container_name: keepalived-master + restart: unless-stopped + network_mode: host + cap_add: + - NET_ADMIN + - NET_RAW + - NET_BROADCAST + volumes: + - ./keepalived.conf:/etc/keepalived/keepalived.conf:ro +``` + +File `keepalived.conf`: +```text +vrrp_instance VI_1 { + state MASTER + interface enp1s0 + virtual_router_id 51 + priority 100 + advert_int 1 + + unicast_src_ip 192.168.0.109 # Replace with Master node's actual IP + unicast_peer { + 192.168.0.110 # Replace with Backup node's actual IP + } + + authentication { + auth_type PASS + auth_pass secret + } + + virtual_ipaddress { + 192.168.0.115/24 # The shared Virtual IP (VIP) + } +} +``` + +## Backup node + +File `docker-compose.yml`: +```yml +services: + keepalived: + image: osixia/keepalived:latest + container_name: keepalived-backup + restart: unless-stopped + network_mode: host + cap_add: + - NET_ADMIN + - NET_RAW + - NET_BROADCAST + volumes: + - ./keepalived.conf:/etc/keepalived/keepalived.conf:ro +``` + +File `keepalived.conf`: +```text +vrrp_instance VI_1 { + state BACKUP + interface enp1s0 + virtual_router_id 51 + priority 90 + advert_int 1 + + unicast_src_ip 192.168.0.110 # Replace with Backup node's actual IP + unicast_peer { + 192.168.0.109 # Replace with Master node's actual IP + } + + authentication { + auth_type PASS + auth_pass secret + } + + virtual_ipaddress { + 192.168.0.115/24 # The shared Virtual IP (VIP) + } +} +```