docker配置keepalive
节点192.168.182.143192.168.182.144加载镜像 keepalived.tar.gzdocker load -ikeepalived.tar.gz192.168.182.144节点[root@hostname-144 k8s-hatools]# cat kconf/keepalived.conf! Configuration File for keepalivedgloba
·
节点
192.168.182.143
192.168.182.144
加载镜像 keepalived.tar.gz
docker load -i keepalived.tar.gz
192.168.182.144节点
[root@hostname-144 k8s-hatools]# cat kconf/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id LVS_HARBOR_2
}
vrrp_script checkhaproxy
{
script "/opt/check.sh"
interval 1
weight -30
}
vrrp_instance VI_3 {
state BACKUP
interface ens33
virtual_router_id 144
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass aaaqaz
}
virtual_ipaddress {
192.168.182.146/24
}
track_script
{
checkhaproxy
}
}
配置检查脚本
[root@hostname-144 k8s-hatools]# cat kconf/check.sh
#!/bin/bash
count=`netstat -ntl | grep 1331 | wc -l`
if [ $count -gt 0 ]; then
exit 0
else
exit 1
fi
192.168.182.143节点
[root@hostname-143 k8s-hatools]# cat kconf/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id LVS_HARBOR_1
}
vrrp_script checkhaproxy
{
script "/opt/check.sh"
interval 1
weight -30
}
vrrp_instance VI_3 {
state MASTER
interface ens33
virtual_router_id 144
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass aaaqaz
}
virtual_ipaddress {
192.168.182.146/24
}
track_script
{
checkhaproxy
}
}
这里的state MASTER ;priority 100; router_id LVS_HARBOR_1需要修改
[root@hostname-144 k8s-hatools]# cat kconf/check.sh
#!/bin/bash
count=`netstat -ntl | grep 1331 | wc -l`
if [ $count -gt 0 ]; then
exit 0
else
exit 1
fi
在两个节点都写上启动脚本,并启动
[root@hostname-144 k8s-hatools]# cat run-keepalived.sh
docker run -d --name harbor-keepalive --restart=always --cap-add=NET_ADMIN --cap-add=NET_BROADCAST --cap-add=NET_RAW --net=host -v ${PWD}/kconf/keepalived.conf:/container/service/keepalived/assets/keepalived.conf -v ${PWD}/kconf/check.sh:/opt/check.sh --detach osixia/keepalived:2.0.20 --copy-service
验证
配置说明
推荐配置说明https://www.cnblogs.com/rexcheny/p/10778567.html
更多推荐
已为社区贡献1条内容
所有评论(0)