#!/usr/bin/env bash # Build ha-sync and ha-sync-ui images and load them onto all k8s worker nodes. # Run from the services/ha-sync directory (or via: make load). set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" NODE1_IP="192.168.2.100" # kube-node-1 (control-plane + worker) NODE2_IP="192.168.2.195" # kube-node-2 (worker) NODE3_IP="192.168.2.196" # kube-node-3 (worker) echo "=== Building ha-sync:latest ===" docker build -t ha-sync:latest -f "$SCRIPT_DIR/Dockerfile" --target ha-sync "$SCRIPT_DIR" echo "=== Building ha-sync-ui:latest ===" docker build -t ha-sync-ui:latest -f "$SCRIPT_DIR/Dockerfile" --target ha-sync-ui "$SCRIPT_DIR" load_image() { local img="$1" local node="$2" local user="$3" echo " → $img → $user@$node" docker save "$img" | ssh "$user@$node" "sudo ctr --namespace k8s.io images import -" } echo "=== Loading images onto kube-node-1 ($NODE1_IP) ===" load_image ha-sync:latest "$NODE1_IP" dan load_image ha-sync-ui:latest "$NODE1_IP" dan echo "=== Loading images onto kube-node-2 ($NODE2_IP) ===" load_image ha-sync:latest "$NODE2_IP" dan load_image ha-sync-ui:latest "$NODE2_IP" dan echo "=== Loading images onto kube-node-3 ($NODE3_IP) ===" load_image ha-sync:latest "$NODE3_IP" dan load_image ha-sync-ui:latest "$NODE3_IP" dan echo "" echo "=== Images loaded on all nodes. Next steps: ===" echo "" echo " 1. Create the DB secret (first time only):" echo " kubectl -n infrastructure create secret generic ha-sync-db-secret \\" echo " --from-literal=dsn='ha-sync:PASSWORD@tcp(general-purpose-db.infrastructure.svc.cluster.local:3306)/general_db?parseTime=true'" echo "" echo " 2. Apply manifests:" echo " kubectl apply -k /home/dan/homelab/deployment/ha-sync/" echo "" echo " 3. Check status:" echo " kubectl get all -n infrastructure -l 'app in (ha-sync,ha-sync-ui)'"