mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 12:03:59 +00:00
Brings up the smallest k3d-resident stack that lets a host-side knoe-auth
(run via `mvn spring-boot:run` or IntelliJ) iterate against real Postgres
+ Kerberos. Closes Phase 1 of the k3d-gke-mirror plan (docs/plans/k3d-gke-mirror.md).
Scope:
- k8s/knoe/knoe-kdc-{configmap,deployment,service,pvc,init-job}.yaml
NEW; standalone KDC, realm KNOE.LOCAL (distinct from KNOE.DEV).
- etc/init_knoe_auth.sh: --mode k3d flag added; swaps realm + skips
GCP-specific steps. GKE behavior unchanged when flag absent.
- Makefile: k3d-knoe-up, k3d-knoe-pf, k3d-knoe-down (delegate to
scripts/k3d-knoe-{up,pf,down}.sh).
- scripts/k3d-knoe-{up,pf,down,smoke}.sh NEW; up = full bring-up,
pf = three port-forwards (5432/88/464) + JDBC URL + ^C cleanup,
down = teardown, smoke = sanity check.
- etc/krb5.local.conf NEW; checked-in libdefaults+realms config
pointing at localhost:88. udp_preference_limit=1 to dodge
kubectl port-forward UDP flakiness on macOS.
- docs/local-dev-knoe-auth.md NEW; one-time setup + daily loop +
IntelliJ run config.
- docs/knoe-system.md NEW; unified reference for the knoe-auth
service (GKE deployment + k3d dev loop + schema overview +
source map + open work items).
Verified per the brief's Definition of done: fresh-clone laptop can
`make k3d-knoe-up` + `make k3d-knoe-pf` + `mvn -pl authority spring-boot:run`
and hit /health, /.well-known/openid-configuration in <8 minutes.
Out of scope (parent plan docs/plans/k3d-gke-mirror.md §6):
- SPNEGO from host browsers (Phase 2)
- knoe-auth-as-pod / image build/load (Phase 3)
- Supabase stack on k3d (Phase 4)
- OidcCodeService DB persistence (separate track)
docs/plans/junie/README.md — k3d brief moved from Active to Shipped.
docs/TODO.md — In-progress now empty; Phase 2 pg_oauth notes that the
local dev loop is in place so it can resume.
Closes Phase 1; Phase 2+ briefs filed as needed.
Co-authored-by: Junie <junie@jetbrains.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
94 lines
4.7 KiB
Bash
Executable File
94 lines
4.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# scripts/k3d-knoe-pf.sh
|
|
# Open port-forwards for the k3d-knoe dev cluster and print connection info.
|
|
#
|
|
# Forwards:
|
|
# localhost:5432 → service/knoe-db-rw (CNPG primary, namespace knoe-db-0)
|
|
# localhost:88 → service/knoe-kdc:88 (Kerberos KDC, namespace knoe-system)
|
|
# localhost:464 → service/knoe-kdc:464 (kpasswd, namespace knoe-system)
|
|
#
|
|
# Usage:
|
|
# make k3d-knoe-pf # foreground; ^C to stop
|
|
# make k3d-knoe-pf & # background (for scripts)
|
|
#
|
|
# Prerequisites: kubectl, k3d cluster running (make k3d-knoe-up)
|
|
|
|
set -euo pipefail
|
|
|
|
CLUSTER_NAME="${K3D_CLUSTER_NAME:-k3d-knoe}"
|
|
CTX="k3d-${CLUSTER_NAME}"
|
|
DB_NS="knoe-db-0"
|
|
SYS_NS="knoe-system"
|
|
|
|
log() { echo "[k3d-knoe-pf] $*"; }
|
|
|
|
kube() { kubectl --context="$CTX" "$@"; }
|
|
|
|
# ── Verify cluster is reachable ───────────────────────────────────────────────
|
|
|
|
if ! kube cluster-info >/dev/null 2>&1; then
|
|
echo "[k3d-knoe-pf] ERROR: Cannot reach cluster context '$CTX'." >&2
|
|
echo " Run: make k3d-knoe-up" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# ── Retrieve DB password for display ─────────────────────────────────────────
|
|
|
|
DB_PASSWORD=$(kube -n "$DB_NS" get secret knoe-db-user \
|
|
-o jsonpath='{.data.password}' 2>/dev/null | base64 -d 2>/dev/null || echo "knoe-dev-password")
|
|
|
|
# ── Print connection info ─────────────────────────────────────────────────────
|
|
|
|
echo ""
|
|
echo "┌─────────────────────────────────────────────────────────────────┐"
|
|
echo "│ k3d-knoe port-forwards │"
|
|
echo "├─────────────────────────────────────────────────────────────────┤"
|
|
echo "│ DB: localhost:5432 (CNPG primary, knoe-db-0) │"
|
|
echo "│ KDC: localhost:88 (Kerberos KDC, knoe-system) │"
|
|
echo "│ kpasswd: localhost:464 (kpasswd, knoe-system) │"
|
|
echo "├─────────────────────────────────────────────────────────────────┤"
|
|
echo "│ JDBC URL: │"
|
|
echo "│ jdbc:postgresql://localhost:5432/knoe-db?sslmode=require │"
|
|
echo "│ │"
|
|
echo "│ Export these before running knoe-auth: │"
|
|
echo "│ export KRB5_CONFIG=\$PWD/etc/krb5.local.conf │"
|
|
echo "│ export KNOE_DB_PASSWORD=${DB_PASSWORD} │"
|
|
echo "│ export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/knoe-db?sslmode=require │"
|
|
echo "│ export SPRING_DATASOURCE_USERNAME=knoe │"
|
|
echo "│ export SPRING_DATASOURCE_PASSWORD=${DB_PASSWORD} │"
|
|
echo "├─────────────────────────────────────────────────────────────────┤"
|
|
echo "│ Press ^C to stop all port-forwards │"
|
|
echo "└─────────────────────────────────────────────────────────────────┘"
|
|
echo ""
|
|
|
|
# ── Start port-forwards ───────────────────────────────────────────────────────
|
|
|
|
PF_PIDS=()
|
|
|
|
cleanup() {
|
|
log "Stopping port-forwards..."
|
|
for pid in "${PF_PIDS[@]:-}"; do
|
|
kill "$pid" 2>/dev/null || true
|
|
done
|
|
log "Done."
|
|
}
|
|
trap cleanup EXIT INT TERM
|
|
|
|
log "Starting port-forward: localhost:5432 → knoe-db-rw:5432 (knoe-db-0)..."
|
|
kube -n "$DB_NS" port-forward service/knoe-db-rw 5432:5432 &
|
|
PF_PIDS+=($!)
|
|
|
|
# Brief pause so the DB forward is established before KDC
|
|
sleep 1
|
|
|
|
log "Starting port-forward: localhost:88 → knoe-kdc:88 (knoe-system)..."
|
|
kube -n "$SYS_NS" port-forward service/knoe-kdc 88:88 &
|
|
PF_PIDS+=($!)
|
|
|
|
log "Starting port-forward: localhost:464 → knoe-kdc:464 (knoe-system)..."
|
|
kube -n "$SYS_NS" port-forward service/knoe-kdc 464:464 &
|
|
PF_PIDS+=($!)
|
|
|
|
log "All port-forwards running. Waiting (^C to stop)..."
|
|
wait
|