#!/usr/bin/bash
# k8s/probe-nodes.sh — verify SSH + Tailscale reachability on all cnodes
set -uo pipefail
source "$(cd "$(dirname "$0")" && pwd)/env.sh"

for ip in "${ALL_CNODES[@]}"; do
  echo "=== $ip ==="
  ssh "${SSH_OPTS[@]}" "${SSH_USER}@${ip}" \
    'echo "host=$(hostname)"; \
     echo "tailscale_ip=$(tailscale ip -4)"; \
     echo "k3s=$(systemctl is-active k3s 2>/dev/null)"; \
     echo "kernel=$(uname -r)"; \
     free -h | head -2; \
     df -h / | tail -1' 2>&1 || echo "FAILED to reach $ip"
  echo
done
