[+] add k3s
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 17s
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 17s
This commit is contained in:
parent
6535e48260
commit
a593dea13c
36
init-k3s.sh
Normal file
36
init-k3s.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
current_ip=$(hostname -I | awk '{print $1}')
|
||||
|
||||
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -s - \
|
||||
--cluster-cidr $pod_subnet \
|
||||
--service-cidr $service_subnet
|
||||
|
||||
# 安装 keepalived
|
||||
apt install -y keepalived
|
||||
|
||||
# 检查是否为 Master-01
|
||||
if [ "$current_ip" == "$master" ]; then
|
||||
state=MASTER
|
||||
priority=100
|
||||
else
|
||||
state=BACKUP
|
||||
priority=100
|
||||
fi
|
||||
|
||||
# 初始化 VIP
|
||||
cat <<EOF | sudo tee /etc/keepalived/keepalived.conf
|
||||
vrrp_instance VI_1 {
|
||||
state $state
|
||||
interface eth0
|
||||
virtual_router_id 51
|
||||
priority $priority
|
||||
advert_int 1
|
||||
virtual_ipaddress {
|
||||
$vip
|
||||
}
|
||||
}
|
||||
EOF
|
||||
sudo systemctl restart keepalived
|
||||
systemctl status keepalived &
|
||||
echo "初始化 master VIP[$state] $current_ip 成功"
|
Loading…
x
Reference in New Issue
Block a user