mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 16:24:32 +00:00
46 lines
1.4 KiB
Bash
46 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Join an additional K3s server (pi.prole.org) to the existing cluster using k3sup.
|
|
# Default topology: HA embedded etcd with at least two servers.
|
|
|
|
set -euo pipefail
|
|
|
|
: "${K3S_EXISTING_SERVER_HOST:=raspberry.prole.org}"
|
|
: "${K3S_EXISTING_SERVER_USER:=pi}"
|
|
: "${K3S_ADDITIONAL_SERVER_HOST:=pi.prole.org}"
|
|
: "${K3S_ADDITIONAL_SERVER_USER:=pi}"
|
|
: "${K3S_SSH_KEY:=$HOME/.ssh/id_rsa}"
|
|
: "${K3S_VERSION:=}"
|
|
|
|
# You likely want your public name(s) here so clients can connect via hostname
|
|
# You may include multiple --tls-san by space-separating them.
|
|
K3S_EXTRA_ARGS_DEFAULT="--tls-san ${K3S_EXISTING_SERVER_HOST} --tls-san ${K3S_ADDITIONAL_SERVER_HOST}"
|
|
: "${K3S_EXTRA_ARGS:=${K3S_EXTRA_ARGS_DEFAULT}}"
|
|
|
|
echo "[info] Joining ${K3S_ADDITIONAL_SERVER_HOST} as additional K3s server to cluster at ${K3S_EXISTING_SERVER_HOST}"
|
|
|
|
if ! command -v k3sup >/dev/null 2>&1; then
|
|
echo "[error] k3sup is not installed. See https://github.com/alexellis/k3sup" >&2
|
|
exit 1
|
|
fi
|
|
|
|
K3SUP_ARGS=(join \
|
|
--server \
|
|
--ip "${K3S_ADDITIONAL_SERVER_HOST}" \
|
|
--user "${K3S_ADDITIONAL_SERVER_USER}" \
|
|
--ssh-key "${K3S_SSH_KEY}" \
|
|
--server-ip "${K3S_EXISTING_SERVER_HOST}" \
|
|
--server-user "${K3S_EXISTING_SERVER_USER}" \
|
|
--k3s-extra-args "${K3S_EXTRA_ARGS}"
|
|
)
|
|
|
|
if [[ -n "${K3S_VERSION}" ]]; then
|
|
K3SUP_ARGS+=(--k3s-version "${K3S_VERSION}")
|
|
fi
|
|
|
|
set -x
|
|
k3sup "${K3SUP_ARGS[@]}"
|
|
set +x
|
|
|
|
echo "[ok] ${K3S_ADDITIONAL_SERVER_HOST} joined as an additional K3s server"
|