k8s worker节点部署Keepalived

默认分类 · 2023-09-05

局域网里挑了个节点安装了dnsmasq做本地域名解析,本地域名解析到一个固定的worker ip会有单点故障的风险,需要装keepalived来保持一个虚拟ip做本地解析,给其他依赖于域名解析的服务提供高可用入口

安装

yum和apt源都有预编译的包,就不需要自己编译了

yum install keepalived

配置

修改配置文件/etc/keepalived/keepalived.conf

global_defs {
   router_id sp-local-keepalived
}

# 检查本机80端口状态
vrrp_script nginx_api_check {
  script "/usr/bin/curl http://127.0.0.1:80 &>/dev/null"
  interval 10
  timeout 5
  rise 1
  fall 2
}

vrrp_instance VI_1 {
    state MASTER # 主节点写MASTER,从节点写BACKUP
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass k8s-worker
    }
    virtual_ipaddress {
        192.168.70.166 # keepalived保持的虚拟ip,可以保持多个ip
        192.168.70.167
    }
}

启动服务

systemctl start keepalived
systemctl enable keepalived
Theme Jasmine by Kent Liao