baguwes/keepalived
Image base on Repo https://github.com/osixia/docker-keepalived
153
Install modprobe
# enable ip_vs
sudo modprobe ip_vs
# configure system
# see: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/load_balancer_administration/s1-initial-setup-forwarding-vsa
sudo sysctl -w net.ipv4.ip_forward=1
sudo sysctl -w net.ipv4.ip_nonlocal_bind=1
LB1 keepalived-env.yaml
KEEPALIVED_COMMAND_LINE_ARGUMENTS: --log-detail --dump-conf
KEEPALIVED_INTERFACE: eth0
KEEPALIVED_PASSWORD: d0cker
# For electing MASTER, highest priority wins.
# to be MASTER, make 50 more than other machines
KEEPALIVED_PRIORITY: 200
KEEPALIVED_UNICAST_PEERS:
- your-ip-lb2
# if you have 3 cluster, add another ip node keepalived
# - your-another-lb
KEEPALIVED_VIRTUAL_IPS:
- your-virtual-ip
# If Need another Virtual IP
# - your-another-virtual-ip
KEEPALIVED_NOTIFY: /container/service/keepalived/assets/notify.sh
KEEPALIVED_ROUTER_ID: 51
KEEPALIVED_STATE: MASTER
LB2 keepalived-env.yaml
KEEPALIVED_COMMAND_LINE_ARGUMENTS: --log-detail --dump-conf
KEEPALIVED_INTERFACE: eth0
KEEPALIVED_PASSWORD: d0cker
# For electing MASTER, highest priority wins.
# to be MASTER, make 50 more than other machines
KEEPALIVED_PRIORITY: 100
KEEPALIVED_UNICAST_PEERS:
- your-ip-lb1
# if you have 3 cluster, add another ip node keepalived
# - your-another-lb
KEEPALIVED_VIRTUAL_IPS:
- your-virtual-ip
# If Need another Virtual IP
# - your-another-virtual-ip
KEEPALIVED_NOTIFY: /container/service/keepalived/assets/notify.sh
KEEPALIVED_ROUTER_ID: 51
KEEPALIVED_STATE: BACKUP
create docker-compose.yml on LB1 & LB2
services:
keepalived:
container_name: keepalived
image: "baguwes/keepalived:v2.0.20"
restart: always
logging:
driver: json-file
options:
max-size: 32m
cap_add:
- NET_ADMIN
- NET_BROADCAST
- NET_RAW
volumes:
- "./keepalived-env.yaml:/container/environment/01-custom/env.yaml"
network_mode: host
haproxy:
container_name: haproxy
image: "haproxy:2.0-alpine"
restart: always
logging:
driver: json-file
options:
max-size: 32m
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
ports:
- 9000:9000/tcp
- 6443:6443/tcp
- 53:53/tcp
- 53:53/udp
- 1194:1194/tcp
- 1195:1195/udp
- 80:80/tcp
- 443:443/tcp
- 22:22/tcp
- 25:25
- 465:465
- 587:587
- 993:993
sysctls:
- net.ipv4.ip_unprivileged_port_start=0
docker pull baguwes/keepalived