测试集群部署
This commit is contained in:
parent
865b9af4d6
commit
c2ae899716
@ -4,9 +4,7 @@ MASTER2="10.0.0.12"
|
||||
MASTER3="10.0.0.13"
|
||||
|
||||
# master 节点的网卡设备名
|
||||
MASTER1_NIC="eth0"
|
||||
MASTER2_NIC="eth0"
|
||||
MASTER3_NIC="eth0"
|
||||
NETWORK_NIC="eth0"
|
||||
|
||||
# api server 填vip或者负载均衡的地址
|
||||
API_SERVER="10.0.0.10"
|
24
cluster.sh
24
cluster.sh
@ -8,8 +8,28 @@ if [ $(id -u) != "0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# 生成keepalived配置文件
|
||||
git
|
||||
sed -e "s/__MASTER1__/${MASTER1}/g" \
|
||||
-e "s/__MASTER2__/${MASTER2}/g" \
|
||||
-e "s/__MASTER3__/${MASTER3}/g" \
|
||||
-e "s/__VIP__/${VIP}/g" \
|
||||
-e "s/__NETWORK_NIC__/${NETWORK_NIC}/g" \
|
||||
-i keepalived/*.conf
|
||||
|
||||
# 分发仓库文件
|
||||
scp -r * root@${MASTER1}:/tmp/
|
||||
scp -r * root@${MASTER2}:/tmp/
|
||||
scp -r * root@${MASTER3}:/tmp/
|
||||
|
||||
# 分发配置
|
||||
ssh root@${MASTER1} "cd /tmp/keepalived/ && cp keepalived1.conf /etc/keepalived/keepalived.conf && bash install.sh"
|
||||
ssh root@${MASTER2} "cd /tmp/keepalived/ && cp keepalived2.conf /etc/keepalived/keepalived.conf && bash install.sh"
|
||||
ssh root@${MASTER3} "cd /tmp/keepalived/ && cp keepalived3.conf /etc/keepalived/keepalived.conf && bash install.sh"
|
||||
|
||||
exit 1
|
||||
cd scripts
|
||||
./init.sh
|
||||
sed -e "s/^apiserver=.*/apiserver=${VIP}/g" -i create_cluster.sh
|
||||
./create_cluster.sh
|
||||
./create_cluster.sh ${API_SERVER}
|
||||
./nginx_ingress.sh
|
||||
|
@ -4,16 +4,17 @@ global_defs {
|
||||
}
|
||||
|
||||
vrrp_script check {
|
||||
script "killall -0 kube-apiserver" # 脚本路径
|
||||
script "killall -0 kube-apiserver" # 脚本路径
|
||||
interval 2 # 脚本执行间隔,单位s
|
||||
weight -20 # -254-254之间,检测失败权重减少
|
||||
}
|
||||
|
||||
vrrp_instance VI_1 { # 实例名
|
||||
state MASTER # 3个实例,1个配置MASTER,另外2个配置BACKUP
|
||||
interface ens192
|
||||
state BACKUP # 3个实例,1个配置MASTER,另外2个配置BACKUP, 非抢占式配置BACKUP
|
||||
interface __NETWORK_NIC__
|
||||
virtual_router_id 251 # ID主备需一致
|
||||
priority 100 # 默认权重,3个节点保持不一致,并且MASTER最大,priority之间的差值要小于weight
|
||||
nopreempt # 非抢占式
|
||||
|
||||
authentication {
|
||||
auth_type PASS # 主备验证信息,需一致
|
||||
@ -28,7 +29,7 @@ vrrp_instance VI_1 { # 实例名
|
||||
__MASTER3__
|
||||
}
|
||||
virtual_ipaddress {
|
||||
__VIP__ dev ens192
|
||||
__VIP__ dev __NETWORK_NIC__
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,23 @@
|
||||
global_defs {
|
||||
script_user root # 脚本执行者
|
||||
enable_script_security # 标记脚本安全
|
||||
script_user root
|
||||
enable_script_security
|
||||
}
|
||||
|
||||
vrrp_script check {
|
||||
script "killall -0 kube-apiserver" # 脚本路径
|
||||
interval 2 # 脚本执行间隔,单位s
|
||||
weight -20 # -254-254之间,检测失败权重减少
|
||||
script "killall -0 kube-apiserver"
|
||||
interval 2
|
||||
weight -20
|
||||
}
|
||||
|
||||
vrrp_instance VI_1 { # 实例名
|
||||
state MASTER # 3个实例,1个配置MASTER,另外2个配置BACKUP
|
||||
interface ens192
|
||||
virtual_router_id 251 # ID主备需一致
|
||||
vrrp_instance VI_1 {
|
||||
state BACKUP
|
||||
interface __NETWORK_NIC__
|
||||
virtual_router_id 251
|
||||
priority 99
|
||||
nopreempt
|
||||
|
||||
authentication {
|
||||
auth_type PASS # 主备验证信息,需一致
|
||||
auth_type PASS
|
||||
auth_pass 123456
|
||||
}
|
||||
track_script {
|
||||
@ -28,7 +29,7 @@ vrrp_instance VI_1 { # 实例名
|
||||
__MASTER3__
|
||||
}
|
||||
virtual_ipaddress {
|
||||
__VIP__ dev ens192
|
||||
__VIP__ dev __NETWORK_NIC__
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,23 @@
|
||||
global_defs {
|
||||
script_user root # 脚本执行者
|
||||
enable_script_security # 标记脚本安全
|
||||
script_user root
|
||||
enable_script_security
|
||||
}
|
||||
|
||||
vrrp_script check {
|
||||
script "killall -0 kube-apiserver" # 脚本路径
|
||||
interval 2 # 脚本执行间隔,单位s
|
||||
weight -20 # -254-254之间,检测失败权重减少
|
||||
script "killall -0 kube-apiserver"
|
||||
interval 2
|
||||
weight -20
|
||||
}
|
||||
|
||||
vrrp_instance VI_1 { # 实例名
|
||||
state MASTER # 3个实例,1个配置MASTER,另外2个配置BACKUP
|
||||
interface ens192
|
||||
virtual_router_id 251 # ID主备需一致
|
||||
vrrp_instance VI_1 {
|
||||
state BACKUP
|
||||
interface __NETWORK_NIC__
|
||||
virtual_router_id 251
|
||||
priority 98
|
||||
nopreempt
|
||||
|
||||
authentication {
|
||||
auth_type PASS # 主备验证信息,需一致
|
||||
auth_type PASS
|
||||
auth_pass 123456
|
||||
}
|
||||
track_script {
|
||||
@ -28,7 +29,7 @@ vrrp_instance VI_1 { # 实例名
|
||||
__MASTER2__
|
||||
}
|
||||
virtual_ipaddress {
|
||||
__VIP__ dev ens192
|
||||
__VIP__ dev __NETWORK_NIC__
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user