vincentmli / BPFire

BPFire development tree
12 stars 0 forks source link

BPFire HA for LoxiLB with Keepalived #28

Open vincentmli opened 2 weeks ago

vincentmli commented 2 weeks ago

Add BPFire WebUI for keepalived to create virtual IP for LoxiLB load balancer. a typical keepalived configuration

global_defs {
   notification_email {
     root@mydomain.com
   }
   notification_email_from svr1@mydomain.com
   smtp_server localhost
   smtp_connect_timeout 30
}

vrrp_instance VRRP1 {
    state MASTER
#   Specify the network interface to which the virtual address is assigned
    interface eth0
#   The virtual router ID must be unique to each VRRP instance that you define
    virtual_router_id 41
#   Set the value of priority higher on the master server than on a backup server
    priority 200
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1066
    }
    virtual_ipaddress {
        10.0.0.100/24
    }
}

above keepalived configuration could be used in Perl here doc from WebUI to simplify the generation of keepalived configuration

        print $keepalived_fh <<EOF

global_defs {
   notification_email {
     $email
   }
   notification_email_from $email
   smtp_server $smtp_server
   smtp_connect_timeout $smtp_timeout
}

vrrp_instance VRRP1 {
    state MASTER
#   Specify the network interface to which the virtual address is assigned
    interface $interface
#   The virtual router ID must be unique to each VRRP instance that you define
    virtual_router_id $router_id
#   Set the value of priority higher on the master server than on a backup server
    priority $priority
    advert_int $advert
    authentication {
        auth_type PASS
        auth_pass 1066
    }
    virtual_ipaddress {
        $vip
    }
}
EOF
vincentmli commented 2 weeks ago

need to change keepalived addon as BPFire core package as part of iso/img build

move config/rootfiles/packages/keepalived to config/rootfiles/common/keepalived

vincentmli commented 1 week ago

since both red0 and green0 requires shared/floating virtual IP, virtual IP on red0 for load balancer virtual IP, virtual IP on green0 for virtual gateway IP to endpoint/backend server, so we need to create keepalived VRRP instance for both red0 and green0 interface, for such UI, html/cgi-bin/dhcp.cgi code could be referenced.

dhcp service in HA can be tricky, maybe disable dhcp in HA for simplicity :)

vincentmli commented 6 days ago

dhcp service in HA can be tricky, maybe disable dhcp in HA for simplicity :)

it looks the dhcp router ip is hard coded to green0 interface ip from html/cgi-bin/dhcp.cgi

    #Subnet range definition
    foreach my $itf (@ITFs) {

            print FILE "\toption routers " . $netsettings{"${itf}_ADDRESS"} . ";\n";

we could add DHCP UI with option routers with a shared/floadting ip between HA as default gateway of backend/endpoint server in HA