kubernetes keepalived配置

kubernetes keepalived配置

yum install -y keepalived

echo "
global_defs {
   router_id LVS_DEVEL
}
vrrp_script check_k8s {
    script 'curl -sk https://127.0.0.1:6443'
    interval 3
    weight -2
    fall 10
    rise 2
}
vrrp_instance VI_1 {
    state MASTER
    interface eth0

    virtual_router_id 210
    priority $(ip addr |grep global |grep $(route  |grep default |awk '{print $NF}') |head -n1 |awk '{print $2}' |cut -d '/' -f1 |awk -F '.' '{print (256-$4)}')
    advert_int 1
    authentication {
    auth_type PASS
    auth_pass 2829
    }

    virtual_ipaddress {
    192.168.3.210/22
    }
    track_script {
        check_k8s
    }
}
" >/etc/keepalived/keepalived.conf 


systemctl enable keepalived.service 
systemctl restart keepalived.service
systemctl status keepalived.service 

ip address show eth0

 

posted @ 2019-11-08 13:39  些许记忆  阅读(886)  评论(0编辑  收藏  举报