homelab/services/ha-sync/build-and-load.sh
Dan V deb6c38d7b chore: commit homelab setup — deployment, services, orchestration, skill
- Add .gitignore: exclude compiled binaries, build artifacts, and Helm
  values files containing real secrets (authentik, prometheus)
- Add all Kubernetes deployment manifests (deployment/)
- Add services source code: ha-sync, device-inventory, games-console,
  paperclip, parts-inventory
- Add Ansible orchestration: playbooks, roles, inventory, cloud-init
- Add hardware specs, execution plans, scripts, HOMELAB.md
- Add skills/homelab/SKILL.md + skills/install.sh to preserve Copilot skill
- Remove previously-tracked inventory-cli binary from git index

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-09 08:10:32 +02:00

49 lines
1.8 KiB
Bash
Executable file

#!/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)'"