#!/bin/bash # Joins the remaining 19 nodes to the k3s cluster (planck002 = first server). # Usage: K3S_TOKEN= ./scripts/k3s-join.sh set -euo pipefail SERVER_URL="https://192.168.0.110:6443" # planck002 SERVERS=(planck003 planck004) AGENTS=(planck001 planck005 planck006 planck007 planck008 planck009 planck010 planck011 planck012 planck013 planck014 planck015 planck016 planck017 planck018 planck019 planck020) [ -n "${K3S_TOKEN:-}" ] || { echo "K3S_TOKEN env required"; exit 1; } export K3S_TOKEN join_server() { ssh -o BatchMode=yes adamcarr@$1.local \ "curl -sfL https://get.k3s.io | sudo K3S_TOKEN='$K3S_TOKEN' sh -s - server --server '$SERVER_URL' --write-kubeconfig-mode 644" \ 2>&1 | grep -viE "rptl.io|newuser" | tail -1 echo "joined server: $1" } join_agent() { ssh -o BatchMode=yes adamcarr@$1.local \ "curl -sfL https://get.k3s.io | sudo K3S_URL='$SERVER_URL' K3S_TOKEN='$K3S_TOKEN' sh -s -" \ 2>&1 | grep -viE "rptl.io|newuser" | tail -1 echo "joined agent: $1" } for s in "${SERVERS[@]}"; do join_server "$s"; done for a in "${AGENTS[@]}"; do join_agent "$a" & done wait echo "all join commands issued"