跳转到主要内容

docker-keepalived

keepalived是一个双活方案,是用arp伪造的方式,确定一个虚拟IP对应到多台主机的当前的实际主机,keepalived采用集群方式部署,节点之间互相通讯和选举,确定某一台机器可用,然后伪造出arp,以达到双活的目的。可以直接在主机安装,也可以使用docker安装

参考网址:https://github.com/osixia/docker-keepalived

当我们搭建高可用K8S时,可以选择kube-vip方案,也可以选择keepalived方案


version: '3'
services:
  keepalived:
    image: harbor.iovhm.com/hub/osixia/keepalived:2.0.20
    restart: always
    network_mode: host
    cap_add:
      - NET_ADMIN
      - NET_BROADCAST
      - NET_RAW
    environment:
      - KEEPALIVED_INTERFACE=eth0           # 网络接口
      # - KEEPALIVED_PASSWORD=d0cker        # 密码
      # - KEEPALIVED_PRIORITY=100           # 节点优先级
      # - KEEPALIVED_ROUTER_ID=51           # 路由ID
      - KEEPALIVED_UNICAST_PEERS="#PYTHON2BASH:['172.18.32.221','172.18.32.98','172.18.32.30']" # 主机列表
      - KEEPALIVED_VIRTUAL_IPS=172.18.32.41/24 # 虚拟IP