keepalived+haproxy+6443端口
cp /usr/share/doc/keepalived/samples/keepalived.conf.vrrp /etc/keepalived/ root@ubuntu20:~# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen } # notification_email_from Alexandre.Cassen@firewall.loc #smtp_server 192.168.200.1 # smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_instance VI_1 { state MASTER interface eth0 garp_master_delay 10 smtp_alert virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.192.188 dev eth0 label eth0:0 } } cat: cat: No such file or directory ! Configuration File for keepalived global_defs { notification_email { acassen } # notification_email_from Alexandre.Cassen@firewall.loc #smtp_server 192.168.200.1 # smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_instance VI_1 { state BACKUP interface eth0 garp_master_delay 10 smtp_alert virtual_router_id 51 priority 99 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.192.188 dev eth0 label eth0:0 } } ##### vi /etc/haproxy/haproxy.cfg listen k8s-6443 bind 192.168.192.188:6443 mode http #tcp server k8s1 192.168.192.151:6443 check inter 3s fall 3 rise 5 server k8s2 192.168.192.152:6443 check inter 3s fall 3 rise 5 server k8s3 192.168.192.153:6443 check inter 3s fall 3 rise 5
cat /etc/sysctl.conf
net.ipv4.ip_nonlocal_bind = 1
root@ubuntu20:~# sysctl -p
root@ubuntu20:~# ip -4 a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
inet 192.168.192.151/21 brd 192.168.199.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.192.188/32 scope global eth0:0
valid_lft forever preferred_lft forever
root@ubuntu20:~# netstat -nutpl|grep haproxy
tcp 0 0 192.168.192.188:6443 0.0.0.0:* LISTEN 922/haproxy