Some checks failed
CI/CD / typecheck (pull_request) Failing after 12s
CI/CD / lint (pull_request) Failing after 22s
CI/CD / test (pull_request) Failing after 10s
CI/CD / build (pull_request) Has been skipped
CI/CD / publish-rpm (pull_request) Has been skipped
CI/CD / publish-deb (pull_request) Has been skipped
k3s host prep: - Add iSCSI initiator install+enable (Fedora: iscsi-initiator-utils, Ubuntu: open-iscsi) — required by Longhorn - Add Longhorn disk label to k3s server+agent configs - Add Longhorn disk annotation operation in post-install hardening CLI: - Add `labctl provision asahi` command with interactive install guide - Change default SSH user from "michal" to "lab" in all commands - Change admin user in bastion progress callback to "lab" Asahi provisioning fixes: - Download installer_data.json locally (installer reads it as file) - Use REPO_BASE to serve upstream ZIP from bastion (LAN speed) - Fix ZIP32 vs ZIP64: serve original upstream ZIP unmodified (our repackaged ZIP used ZIP64 which breaks Asahi urlcache) - Add /data/asahi-repo fallback path for k3s container PVC mount - Deploy script syncs asahi-repo to bastion pod after deployment Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
90 lines
3.1 KiB
Bash
90 lines
3.1 KiB
Bash
#!/bin/bash
|
|
# Deploy bastion + labd to k3s cluster and install labctl locally.
|
|
# Usage: ./scripts/deploy.sh [bastion|labd|labctl|all]
|
|
#
|
|
# Builds container images with existing build scripts, pushes to Gitea
|
|
# registry, restarts k3s pods, and builds/installs labctl RPM.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
cd "$PROJECT_DIR"
|
|
|
|
# Load .env if present
|
|
if [ -f .env ]; then
|
|
set -a; source .env; set +a
|
|
fi
|
|
|
|
deploy_bastion() {
|
|
echo "=== Building & pushing bastion image ==="
|
|
bash scripts/build-bastion.sh --push latest
|
|
echo ""
|
|
echo "=== Restarting bastion pod ==="
|
|
kubectl rollout restart deployment/bastion -n lab-infra
|
|
kubectl rollout status deployment/bastion -n lab-infra --timeout=180s
|
|
echo "✓ Bastion deployed"
|
|
|
|
# Sync Asahi rootfs package to bastion pod's persistent volume
|
|
if [ -d "$PROJECT_DIR/asahi-repo" ] && [ -f "$PROJECT_DIR/asahi-repo/fedora-asahi-lab.zip" ]; then
|
|
echo ""
|
|
echo "=== Syncing Asahi rootfs to bastion pod ==="
|
|
BASTION_POD=$(kubectl get pods -n lab-infra -l app=bastion -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
|
|
if [ -n "$BASTION_POD" ]; then
|
|
kubectl exec -n lab-infra "$BASTION_POD" -- mkdir -p /data/asahi-repo
|
|
kubectl cp "$PROJECT_DIR/asahi-repo/installer_data.json" "lab-infra/$BASTION_POD:/data/asahi-repo/installer_data.json"
|
|
kubectl cp "$PROJECT_DIR/asahi-repo/fedora-asahi-lab.zip" "lab-infra/$BASTION_POD:/data/asahi-repo/fedora-asahi-lab.zip"
|
|
echo "✓ Asahi rootfs synced ($(du -sh "$PROJECT_DIR/asahi-repo/fedora-asahi-lab.zip" | cut -f1))"
|
|
else
|
|
echo "WARNING: Could not find bastion pod — Asahi rootfs not synced"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
deploy_labd() {
|
|
echo "=== Building & pushing labd image ==="
|
|
bash scripts/build-labd.sh --push latest
|
|
echo ""
|
|
echo "=== Restarting labd pod ==="
|
|
kubectl rollout restart deployment/labd -n lab-system
|
|
kubectl rollout status deployment/labd -n lab-system --timeout=180s
|
|
echo "✓ Labd deployed"
|
|
}
|
|
|
|
deploy_labctl() {
|
|
echo "=== Building labctl RPM ==="
|
|
bash scripts/build-rpm.sh
|
|
echo ""
|
|
echo "=== Installing labctl ==="
|
|
RPM_FILE=$(ls dist/labctl-*.x86_64.rpm 2>/dev/null | head -1)
|
|
if [ -n "$RPM_FILE" ]; then
|
|
sudo rpm -U --force "$RPM_FILE"
|
|
echo "✓ labctl installed: $(labctl --version 2>/dev/null || echo 'installed')"
|
|
else
|
|
echo "WARNING: No RPM found, falling back to direct install"
|
|
pnpm build
|
|
sudo install -m 755 <(echo '#!/bin/bash'; echo "exec node $PROJECT_DIR/src/cli/dist/index.js \"\$@\"") /usr/local/bin/labctl
|
|
echo "✓ labctl installed (dev mode)"
|
|
fi
|
|
}
|
|
|
|
case "${1:-all}" in
|
|
bastion) deploy_bastion ;;
|
|
labd) deploy_labd ;;
|
|
labctl) deploy_labctl ;;
|
|
all)
|
|
deploy_bastion
|
|
echo ""
|
|
deploy_labd
|
|
echo ""
|
|
deploy_labctl
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [bastion|labd|labctl|all]"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo ""
|
|
echo "=== Deploy complete ==="
|