k3sノードのkeepalivedによる冗長化

Masterノードでは systemctl is-active k3sにする.

/etc/keepalived/keepalived.conf

vrrp_script chk_k8s {
    script "systemctl is-active k3s-agent"
}
vrrp_instance VI_1 {
    state MASTER
    interface ens160
    virtual_router_id 31
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass vd2j8OdBj1jrCuL9b0BJ
    }
    virtual_ipaddress {
        192.168.210.220
    }
    track_script {
        chk_k8s
    }
}

keepalivedの永続化と起動

sudo systemctl enable keepalived
sudo systemctl start keepalived

k3sを停止して挙動を確認

sudo systemctl stop k3s
sudo systemctl stop k3s-agent