#!/usr/bin/env bash # Worker join (Terraform design 7.2). Feed the join command produced on the CP through stdin, from the operator host: # ssh -i ~/.ssh/selfheal-lab ubuntu@ 'sudo cat /opt/selfheal/join.sh' \ # | ssh -i ~/.ssh/selfheal-lab -J ubuntu@ ubuntu@ 'sudo bash /opt/selfheal/gitops/bootstrap/kubeadm/join-worker.sh' # The token never touches the operator terminal or a log. Safe to re-run: a joined node exits 0. set -euo pipefail if [ -f /etc/kubernetes/kubelet.conf ]; then echo "already joined"; exit 0; fi JOIN="$(cat)" case "$JOIN" in kubeadm\ join*) ;; *) echo "stdin is not a kubeadm join command" >&2; exit 1;; esac # shellcheck disable=SC2086 $JOIN --node-name "$(hostname)" echo "joined"