K3S HA etcd
Additional Preparation for Alpine Linux Setup
$ sudo nano /etc/update-extlinux.conf
…
default_kernel_opts="... cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory"
…
$ sudo update-extlinux
/boot is device /dev/sda1
$ sudo reboot
建立第一個 K3S Master
$ curl -sfL https://get.k3s.io | K3S_TOKEN="mysecret" K3S_KUBECONFIG_MODE="644" sh -s server --cluster-init --cluster-domain=sre
建立其他 K3S Master
$ curl -sfL https://get.k3s.io | K3S_TOKEN="mysecret" K3S_URL="https://120.96.143.83:6443" K3S_KUBECONFIG_MODE="644" sh -s server --cluster-domain=sre
建立 K3S worker
$ curl -sfL https://get.k3s.io | K3S_TOKEN="mysecret" K3S_URL="https://120.96.143.83:6443" K3S_KUBECONFIG_MODE="644" sh -s -
設定 K3S Worker 標籤
於 master 執行
$ kubectl get node
$ sudo kubectl label node 120-96-143-95-k3w95 node-role.kubernetes.io/worker=120-96-143-95-k3w95
於 K3S 建置測試 Pod
$ kubectl run t1 --restart=Never --image=alpine -- sleep 30
pod/t1 created
$ kubectl get pods --watch
NAME READY STATUS RESTARTS AGE
t1 0/1 ContainerCreating 0 8s
t1 1/1 Running 0 12s
t1 0/1 Completed 0 42s
$ kubectl delete pods t1
pod "t1" deleted