diff --git a/docs/infrastructure/kubernetes.md b/docs/infrastructure/kubernetes.md index eedbeee..b2d4474 100644 --- a/docs/infrastructure/kubernetes.md +++ b/docs/infrastructure/kubernetes.md @@ -13,4 +13,89 @@ | ------------- | ----------- | ---------------------- | -------- | | k3s-worker-01 | 10.20.40.21 | AMD Ryzen 5 PRO 2400GE | 48 | | k3s-worker-02 | 10.20.40.22 | Intel i5 8600 | 16 | -| k3s-worker-03 | 10.20.40.23 | Intel i5 8600 | 16 | \ No newline at end of file +| k3s-worker-03 | 10.20.40.23 | Intel i5 8600 | 16 | +## Deployment guide +My cluster is has 3 control planes, this makes it HA. +### Shared VIP for the 3 control planes +#### 1. Install keepalived +```bash +sudo apt install keepalived -y +``` +#### 2. Create config file +```bash +sudo nano /etc/keepalived/keepalived.conf +``` +For the first node, you want the `state` to be "MASTER", for every other node, you want the `state` to be "BACKUP", which decreasing priority for each node. +##### k3s-cp-01 +``` +vrrp_instance VI_1 { + state MASTER + interface eth0 + virtual_router_id 51 + priority 100 + advert_int 1 + authentication { + auth_type PASS + auth_pass REPLACE_THIS_WITH_A_PASSWORD + } + virtual_ipaddress { + 10.20.40.10/24 + } +} +``` +##### k3s-cp-02 +``` +vrrp_instance VI_1 { + state BACKUP + interface eth0 + virtual_router_id 51 + priority 99 + advert_int 1 + authentication { + auth_type PASS + auth_pass REPLACE_THIS_WITH_A_PASSWORD + } + virtual_ipaddress { + 10.20.40.10/24 + } +} +``` +##### k3s-cp-02 +``` +vrrp_instance VI_1 { + state BACKUP + interface eth0 + virtual_router_id 51 + priority 98 + advert_int 1 + authentication { + auth_type PASS + auth_pass REPLACE_THIS_WITH_A_PASSWORD + } + virtual_ipaddress { + 10.20.40.10/24 + } +} +``` +#### 3. Start & enable the service +```bash +sudo systemctl enable --now keepalived +``` +### Initialise the first control plane +```bash +curl -sfL https://get.k3s.io | K3S_TOKEN=REPLACE sh -s - server --cluster-init --tls-san=10.20.40.10 --disable=traefik --disable=servicelb +``` +### Add the other two control planes +```bash +curl -sfL https://get.k3s.io | K3S_TOKEN=REPLACE sh -s - server --server https://10.20.40.10:6443 --tls-san=10.20.40.10 --disable=traefik --disable=servicelb +``` + +### Adding worker nodes +#### 1. grab `K3S_TOKEN` from master +```bash +sudo cat /var/lib/rancher/k3s/server/node-token +``` +#### 2. Add each worker node +``` +curl -sfL https://get.k3s.io | K3S_URL=https://10.20.40.10:6443 K3S_TOKEN=REPLACE sh - +```