Run a single Gitea container on the host (bootstrap/gitea/), outside the cluster, while the cluster is built; Flux pulls this repo from it over the k3s-dev NAT gateway (http://10.73.0.1:3000/Home-Network/home-network-k3s-impl.git, public repo => no creds, NAT-only). Wired the flux-system GitRepository url in clusters/dev. Migrates to in-cluster Gitea in Phase 6. Pins confirmed. Author-only; gate PASS. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
53 lines
2.3 KiB
Bash
Executable File
53 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# bootstrap/gitea/bootstrap-gitea.sh — run a SINGLE Gitea container on the HOST (outside the
|
|
# cluster) as the Phase-1 GitOps bootstrap source. While the cluster is built, Flux (in-cluster)
|
|
# reconciles this repo from the host Gitea over the k3s-dev NAT gateway. This is the "local
|
|
# bootstrap source" that migrates to in-cluster Gitea in Phase 6 (docs/05 "Source-of-truth",
|
|
# CONTRIBUTING.md).
|
|
#
|
|
# Run by the OPERATOR at bring-up — NOT during author-only, NOT by any agent.
|
|
set -euo pipefail
|
|
ENGINE="${ENGINE:-podman}"
|
|
GITEA_IMAGE="${GITEA_IMAGE:-docker.io/gitea/gitea:1.22}" # pinned; bump if needed
|
|
NAME="${GITEA_NAME:-home-k3s-bootstrap-gitea}"
|
|
HTTP_PORT="${GITEA_HTTP_PORT:-3000}"
|
|
SSH_PORT="${GITEA_SSH_PORT:-2222}"
|
|
DATA_DIR="${GITEA_DATA_DIR:-${HOME}/.local/share/home-k3s-bootstrap-gitea}"
|
|
# The cluster VMs reach the host on the k3s-dev NAT gateway (10.73.0.1). ROOT_URL must match so
|
|
# clone/redirect URLs are correct from inside the cluster.
|
|
HOST_NAT_IP="${HOST_NAT_IP:-10.73.0.1}"
|
|
ORG="${GITEA_ORG:-Home-Network}"
|
|
REPO="${GITEA_REPO:-home-network-k3s-impl}"
|
|
|
|
mkdir -p "${DATA_DIR}"
|
|
if "$ENGINE" container exists "$NAME" 2>/dev/null; then
|
|
echo "Gitea container '${NAME}' already exists — starting it."
|
|
"$ENGINE" start "$NAME" >/dev/null
|
|
else
|
|
"$ENGINE" run -d --name "$NAME" --restart unless-stopped \
|
|
-p "${HTTP_PORT}:3000" -p "${SSH_PORT}:22" \
|
|
-v "${DATA_DIR}:/data" \
|
|
-e GITEA__server__ROOT_URL="http://${HOST_NAT_IP}:${HTTP_PORT}/" \
|
|
-e GITEA__server__SSH_PORT="${SSH_PORT}" \
|
|
-e GITEA__security__INSTALL_LOCK=true \
|
|
"$GITEA_IMAGE"
|
|
fi
|
|
|
|
cat <<EOF
|
|
|
|
Gitea (bootstrap source) at http://${HOST_NAT_IP}:${HTTP_PORT}/ data: ${DATA_DIR}
|
|
|
|
One-time setup (manual — keeps creds out of this script):
|
|
1. Create an admin user:
|
|
${ENGINE} exec -u git ${NAME} gitea admin user create \\
|
|
--username <admin> --password <pw> --email <you@example> --admin
|
|
2. In the UI (or API) create org '${ORG}' and a **PUBLIC** repo '${REPO}'
|
|
(public => Flux needs no git credentials; this Gitea is NAT-only, not internet-exposed).
|
|
3. Push this repo up:
|
|
git remote add bootstrap http://<admin>:<pw>@${HOST_NAT_IP}:${HTTP_PORT}/${ORG}/${REPO}.git
|
|
git push bootstrap main
|
|
|
|
Flux's flux-system GitRepository url is already wired to:
|
|
http://${HOST_NAT_IP}:${HTTP_PORT}/${ORG}/${REPO}.git (clusters/dev)
|
|
EOF
|