K3s 嵌入式DB的高可用

K3s 嵌入式DB的高可用

节点

iphostnametype
192.168.163.141k8s-m1master
192.168.163.142k8s-m2master
192.168.163.143k8s-m3master
192.168.163.144k8s-w1work
192.168.163.145k8s-w2work
192.168.163.146k8s-w3work

host 文件配置

192.168.163.141 k8s-m1
192.168.163.142 k8s-m2
192.168.163.143 k8s-m3
192.168.163.144 k8s-w1
192.168.163.145 k8s-w2
192.168.163.146 k8s-w3

配置docker.io 镜像

文件 /etc/rancher/k3s/registries.yaml

mirrors:
  "docker.io":
    endpoint:
      - "https://uvslpyyz.mirror.aliyuncs.com"
      - "https://registry-1.docker.io"

执行命令

k8s-m1

curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_TOKEN=K105ebf0aa70eb6ff378a5c4ca500424580df871e1d9d2c7d623c1393935ac98a0a::server:b7b35eb534a6a7f07b9368dd84ad1447 INSTALL_K3S_EXEC="server --cluster-init" sh -

节点更新ca证书

没有更新ca证书报错starting kubernetes: preparing server: token CA hash does not match the Cluster CA certificate hash: xxxxxxxxw != xxxxxxxx

curl -k https://192.168.163.141:6443/cacerts -o /usr/local/share/ca-certificates/k3s.crt
update-ca-certificates

k8s-m2 k8s-m3

curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_TOKEN=K105ebf0aa70eb6ff378a5c4ca500424580df871e1d9d2c7d623c1393935ac98a0a::server:b7b35eb534a6a7f07b9368dd84ad1447 K3S_URL=https://192.168.163.141:6443 INSTALL_K3S_EXEC="server" sh -

k8s-w1 k8s-w2 k8s-w3

curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_TOKEN=K105ebf0aa70eb6ff378a5c4ca500424580df871e1d9d2c7d623c1393935ac98a0a::server:b7b35eb534a6a7f07b9368dd84ad1447 K3S_URL=https://192.168.163.141:6443 sh -