Keepalived
Allikas: Kuutõrvaja
Paigaldamine
Paigaldamine CentOSis
# yum install keepalived # systemctl enable keepalived
Seadistus
Seadistame kaks keepalived serverit millest üks master ja teine slave. Mõlemad jagavad omavahel 192.168.0.5 virtuaalst aadressi.
Master serveri /etc/keepalived/keepalived.conf
global_defs {
notification_email {
info@test.ee
}
notification_email_from keepalived@Mall:K8s cluster name
smtp_server 192.168.0.10
smtp_connect_timeout 30
router_id minginimi
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
interface eth0 # interface to monitor
state MASTER
virtual_router_id 1
priority 101
virtual_ipaddress {
192.168.0.5
}
track_script {
chk_haproxy
}
}
Slave serveri /etc/keepalived/keepalived.conf
global_defs {
notification_email {
info@test.ee
}
notification_email_from keepalived@Mall:K8s cluster name
smtp_server 192.168.0.10
smtp_connect_timeout 30
router_id minginimi
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
interface eth0 # interface to monitor
state BACKUP
virtual_router_id 1
priority 100
virtual_ipaddress {
192.168.0.5
}
track_script {
chk_haproxy
}
}
Võimalik on panna keepalived programmi enda IP aadressi masterilt slave serverile vahetama ka teataval tingimusel. Näiteks kui serveris enal haproxy protsess ei tööta
vrrp_script chk_haproxy {
script "pidof haproxy" # check the haproxy process
interval 2 # every 2 seconds
weight 2 # add 2 points if OK
}