#!/bin/bash current_ip=$(hostname -I | awk '{print $1}') # 镜像加速 cat < /etc/rancher/k3s/registries.yaml mirrors: docker.io: registry.k8s.io: endpoint: - https://docker.martin98.com/v2/docker https://registry.k8s.io: https://k8s.gcr.io: endpoint: - https://docker.martin98.com/v2/k8s https://gcr.io: endpoint: - https://docker.martin98.com/v2/gcr https://ghcr.io: endpoint: - https://docker.martin98.com/v2/ghcr https://quay.io: endpoint: - https://docker.martin98.com/v2/quay EOF 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 \ --node-external-ip=$vip_ip # 安装 keepalived apt install -y keepalived # 检查是否为 Master-01 if [ "$current_ip" == "$master" ]; then state=MASTER priority=100 else state=BACKUP priority=100 fi # 初始化 VIP cat <