文件
k3s/install
T

替换hostname

hostnamectl set-hostname node && reboot

安装tailscale

curl -fsSL https://tailscale.com/install.sh | sh

开启tailscale的自动更新

tailscale set --auto-update

开启ip转发

echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf sudo sysctl -p /etc/sysctl.d/99-tailscale.conf

新建目录 将不同节点类型的config写入

mkdir -p /etc/rancher/k3s && nano /etc/rancher/k3s/config.yaml

安装k3s 此处注意安装类型 是server 还是 agent

curl -sfL https://get.k3s.io |
INSTALL_K3S_MIRROR=cn
sh -s - server

国内安装加速 & 镜像加速地址

https://rancher-mirror.rancher.cn/k3s/k3s-install.sh nano /etc/rancher/k3s/registries.yaml

查看serverToken 记得在config中替换最新的token

cat /var/lib/rancher/k3s/server/node-token

查看api server config 需要替换到.kube/config中 注意将其中的server地址替换为高可用地址

cat /etc/rancher/k3s/k3s.yaml

给node添加地域标签

kubectl label nodes tca topology.kubernetes.io/region=cn-sh kubectl label nodes tca svccontroller.k3s.cattle.io/enablelb="true"

给master节点添加污点

kubectl taint nodes tca node-role.kubernetes.io/master:NoSchedule