mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 18:14:33 +00:00
Itemized changes:
1. knoe-auth: New cluster-internal KDC and SSO gateway service
- Created etc/init_knoe_auth.sh based on init_kdc.sh with knoe-auth naming
- Namespace defaults to SERVICE_NAMESPACE (knoe-system)
- ConfigMap: knoe-auth-kdc-config, Secret: knoe-auth-secrets
- Legacy cleanup removes old auth/dog/authority deployments
2. Orchestration: knoe-auth initializes before CloudNativePG
- Updated prole.sh to insert init_knoe_auth.sh as step 2 (before CNPG)
- Renumbered all subsequent initialization steps
3. Kong routing: Updated init_kong.sh to route to knoe-auth in SERVICE_NAMESPACE
4. Comment/reference updates for knoe-auth
- Updated init_common_services.sh, init_service_layer.sh, init_kerberos.sh
5. prole-db renamed to knoe-db across the entire codebase
- Renamed prole-db/ directory to knoe-db/
- Renamed all prole-db Kubernetes manifests (deploy/opentofu, k8s/)
- Renamed scripts: docker-root-knoe-db.sh, docker-run-knoe-db.sh, test-cnpg-knoe-db.sh
- Renamed etc/init_prole-db-reset.sh to etc/init_knoe-db-reset.sh
- Renamed etc/prole-db-passwwd.sh to etc/knoe-db-passwwd.sh
- Renamed mock_val counterparts accordingly
- Renamed tests/etc/test_init_prole-db-reset.sh to test_init_knoe-db-reset.sh
- Renamed docs/prole-db-documentation-mcp-architecture.md to knoe-db variant
- Renamed modes/k3d/prole-db/ to modes/k3d/knoe-db/
- Renamed prole-db.iml to knoe-db.iml
6. Configuration updates
- Updated conf/dev, conf/prod, conf/test, conf/service prole.cfg files
- Updated conf/port-mapping.cfg
- Updated etc/prole_cfg.sh and mock_val/prole_cfg.sh
- Updated service/prole.cfg
7. Kubernetes manifests and deploy configuration
- Updated deploy/opentofu/k3s ArgoCD application YAMLs
- Updated kong-configmap.yaml and kustomization.yaml
- Updated k3s/kong-config.yml and prole-resources.yaml
- Updated prole-mssql-db deployment YAMLs
- Updated supabase helm render and deploy scripts
8. Infrastructure and GCP Terraform
- Updated deploy/gcp/terraform: folders, groups, IAM, service-projects
9. Python/installer code updates
- Updated knoe/core: actions, build_context, controller, env, milestones
- Updated knoe/milestone.py
- Updated knoe/ui/screens: cfg, database, database_options, deploy, docker,
navigation, security, services, validate
- Updated knoe.spec, status.py
10. Shell script updates
- Updated etc/: build_db, init_cloudnative_pg, init_cnpg_backup,
init_db_manager, init_forgejo, init_gitlab, init_monitoring, init_openbao,
init_port_forwards, init_postgrest, init_supabase_ports, status
- Updated mock_val/ counterparts for all above scripts
- Updated prole-net/init-prole-dns.sh
- Updated bin/prole-kpf.sh, gitea/deploy.sh, supabase/deploy.sh
11. Test updates
- Updated tests/etc/: test_init_cloudnative_pg*, test_init_cnpg_backup*,
test_init_kdc*, test_init_kerberos*, test_init_kong*, test_prole_cfg*
- Updated tests/installer/: test_actions_helpers, test_cfg_save_kubecontext,
test_controller, test_core_classes, test_milestones, test_milestones_extended,
test_namespace_propagation
- Updated tests/: test_database_options, test_navigation,
test_render_supabase_hostname, test_docker_build_fix,
test_all_prole_home_fixes, silent_install_test, final_test
12. Documentation updates
- Updated docs/: DOCKER-BUILD-FIX, PROLE-CFG-SECRETS, PROLE-HOME-DIRECTORY,
build-system, patent
- Updated scan/network_description.txt
- Updated pom.xml
13. Miscellaneous script updates
- Updated root-level: _adopt_replica_pvcs, _fix_replica_merlin, _import_pi,
_patch_cluster, _prebind_pvcs, _rebind_d002, _rebind_d002b, test_resolve
- Updated scripts/generate_spec.py
Co-authored-by: Junie <junie@jetbrains.com>
244 lines
7.0 KiB
Bash
Executable File
244 lines
7.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# init_supabase_ports.sh
|
|
# Purpose:
|
|
# - Ensure the supabase namespace front-door (svc/db on port 5432)
|
|
# points to knoe-db-rw in the provided namespace.
|
|
# - Ensure the Supabase reference Postgres service is on port 15432
|
|
# and not host-exposed.
|
|
|
|
PROG="init_supabase_ports"
|
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
# Load environment and config via prole_cfg.sh
|
|
# shellcheck disable=SC1090
|
|
source "$SCRIPT_DIR/prole_cfg.sh"
|
|
|
|
if [[ "${1:-}" == "--mode" || "${1:-}" == "-m" ]]; then
|
|
prole_set_mode "${2:-}"
|
|
shift 2
|
|
elif [[ "${1:-}" == --mode=* || "${1:-}" == -m=* ]]; then
|
|
prole_set_mode "${1#*=}"
|
|
shift
|
|
fi
|
|
|
|
SUPABASE_NAMESPACE="${SUPABASE_NAMESPACE:-supabase}"
|
|
KNOE_DB_SERVICE="${KNOE_DB_SERVICE:-knoe-db-rw}"
|
|
SUPABASE_DB_SERVICE="${SUPABASE_DB_SERVICE:-db}"
|
|
SUPABASE_POSTGRES_SERVICE="${SUPABASE_POSTGRES_SERVICE:-supabase-postgres}"
|
|
SUPABASE_POSTGRES_PORT="${SUPABASE_POSTGRES_PORT:-15432}"
|
|
DB_PORT="${DB_PORT:-5432}"
|
|
RESTART_ON_CHANGE=1
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Usage:
|
|
$PROG -n <namespace> [options]
|
|
|
|
Required:
|
|
-n, --namespace <namespace> Namespace that contains svc/$KNOE_DB_SERVICE
|
|
|
|
Options:
|
|
--supabase-namespace <ns> Supabase namespace (default: $SUPABASE_NAMESPACE)
|
|
--no-restart Do not restart Supabase services on change
|
|
-h, --help Show this help
|
|
|
|
Notes:
|
|
- This script creates/updates svc/$SUPABASE_DB_SERVICE in the Supabase namespace
|
|
as an ExternalName pointing to $KNOE_DB_SERVICE.<namespace>.svc.cluster.local:5432.
|
|
- When the target namespace changes, Supabase services are restarted automatically.
|
|
EOF
|
|
}
|
|
|
|
log() { printf '%s\n' "$*"; }
|
|
warn() { printf '[warn] %s\n' "$*"; }
|
|
err() { printf '[error] %s\n' "$*" >&2; }
|
|
|
|
TARGET_NAMESPACE=""
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
-n|--namespace)
|
|
TARGET_NAMESPACE="${2:-}"
|
|
shift 2
|
|
;;
|
|
--supabase-namespace)
|
|
SUPABASE_NAMESPACE="${2:-}"
|
|
shift 2
|
|
;;
|
|
--no-restart)
|
|
RESTART_ON_CHANGE=0
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
err "Unknown argument: $1"
|
|
usage
|
|
exit 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z "$TARGET_NAMESPACE" ]]; then
|
|
err "-n|--namespace is required"
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
ensure_tools() {
|
|
for t in kubectl; do
|
|
command -v "$t" >/dev/null || { err "Missing required tool: $t"; exit 1; }
|
|
done
|
|
}
|
|
|
|
ensure_namespace() {
|
|
if ! kubectl get namespace "$SUPABASE_NAMESPACE" >/dev/null 2>&1; then
|
|
log "Creating namespace '$SUPABASE_NAMESPACE' ..."
|
|
kubectl create namespace "$SUPABASE_NAMESPACE" >/dev/null 2>&1 || true
|
|
fi
|
|
}
|
|
|
|
selector_pairs_to_yaml() {
|
|
local selector="$1"
|
|
local out=""
|
|
local pair key val
|
|
IFS=',' read -ra pairs <<<"$selector"
|
|
for pair in "${pairs[@]}"; do
|
|
pair="$(printf '%s' "$pair" | xargs)"
|
|
[[ -z "$pair" ]] && continue
|
|
key="${pair%%=*}"
|
|
val="${pair#*=}"
|
|
[[ -z "$key" || -z "$val" ]] && continue
|
|
out+=" ${key}: ${val}\n"
|
|
done
|
|
printf '%b' "$out"
|
|
}
|
|
|
|
get_selector_pairs() {
|
|
local out
|
|
out=$(kubectl -n "$SUPABASE_NAMESPACE" get svc "$1" \
|
|
-o jsonpath='{range $k,$v := .spec.selector}{$k}={$v},{end}' 2>/dev/null || true)
|
|
printf '%s' "$out" | sed 's/,$//'
|
|
}
|
|
|
|
restart_supabase() {
|
|
log "Restarting Supabase workloads in namespace '$SUPABASE_NAMESPACE' ..."
|
|
local restarted=0
|
|
|
|
if kubectl -n "$SUPABASE_NAMESPACE" get deploy >/dev/null 2>&1; then
|
|
if kubectl -n "$SUPABASE_NAMESPACE" rollout restart deploy --all >/dev/null 2>&1; then
|
|
restarted=1
|
|
fi
|
|
fi
|
|
|
|
if kubectl -n "$SUPABASE_NAMESPACE" get sts >/dev/null 2>&1; then
|
|
if kubectl -n "$SUPABASE_NAMESPACE" rollout restart statefulset --all >/dev/null 2>&1; then
|
|
restarted=1
|
|
fi
|
|
fi
|
|
|
|
if [[ "$restarted" -eq 0 ]]; then
|
|
warn "Rollout restart not supported; deleting Supabase pods instead."
|
|
kubectl -n "$SUPABASE_NAMESPACE" delete pod --all --ignore-not-found >/dev/null 2>&1 || true
|
|
fi
|
|
}
|
|
|
|
ensure_tools
|
|
ensure_namespace
|
|
|
|
if ! kubectl -n "$TARGET_NAMESPACE" get svc "$KNOE_DB_SERVICE" >/dev/null 2>&1; then
|
|
warn "Service not found: $KNOE_DB_SERVICE in namespace $TARGET_NAMESPACE"
|
|
fi
|
|
|
|
DESIRED_EXTERNAL="${KNOE_DB_SERVICE}.${TARGET_NAMESPACE}.svc.cluster.local"
|
|
|
|
service_exists=0
|
|
current_type=""
|
|
current_external=""
|
|
current_selector=""
|
|
|
|
if kubectl -n "$SUPABASE_NAMESPACE" get svc "$SUPABASE_DB_SERVICE" >/dev/null 2>&1; then
|
|
service_exists=1
|
|
current_type=$(kubectl -n "$SUPABASE_NAMESPACE" get svc "$SUPABASE_DB_SERVICE" -o jsonpath='{.spec.type}' 2>/dev/null || true)
|
|
current_external=$(kubectl -n "$SUPABASE_NAMESPACE" get svc "$SUPABASE_DB_SERVICE" -o jsonpath='{.spec.externalName}' 2>/dev/null || true)
|
|
current_selector=$(get_selector_pairs "$SUPABASE_DB_SERVICE")
|
|
fi
|
|
|
|
namespace_changed=1
|
|
if [[ "$service_exists" -eq 1 && "$current_type" == "ExternalName" && "$current_external" == "$DESIRED_EXTERNAL" ]]; then
|
|
namespace_changed=0
|
|
fi
|
|
|
|
# Preserve selectors from the previous db service for the reference Postgres service.
|
|
DB_SELECTOR="$current_selector"
|
|
if [[ -z "$DB_SELECTOR" ]]; then
|
|
DB_SELECTOR="${SUPABASE_DB_SELECTOR:-io.kompose.service=db}"
|
|
fi
|
|
|
|
if [[ "$service_exists" -eq 1 && "$current_type" != "ExternalName" ]]; then
|
|
log "Replacing service $SUPABASE_NAMESPACE/$SUPABASE_DB_SERVICE with ExternalName -> $DESIRED_EXTERNAL"
|
|
kubectl -n "$SUPABASE_NAMESPACE" delete svc "$SUPABASE_DB_SERVICE" --ignore-not-found >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
log "Ensuring $SUPABASE_NAMESPACE/$SUPABASE_DB_SERVICE points to $DESIRED_EXTERNAL:$DB_PORT"
|
|
cat <<EOF | kubectl apply -f -
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: ${SUPABASE_DB_SERVICE}
|
|
namespace: ${SUPABASE_NAMESPACE}
|
|
annotations:
|
|
prole.org/db-namespace: "${TARGET_NAMESPACE}"
|
|
prole.org/db-service: "${KNOE_DB_SERVICE}"
|
|
spec:
|
|
type: ExternalName
|
|
externalName: ${DESIRED_EXTERNAL}
|
|
ports:
|
|
- name: postgres
|
|
port: ${DB_PORT}
|
|
targetPort: ${DB_PORT}
|
|
EOF
|
|
|
|
# Ensure Supabase reference Postgres service is on 15432 and ClusterIP
|
|
supabase_pg_exists=0
|
|
supabase_pg_type=""
|
|
if kubectl -n "$SUPABASE_NAMESPACE" get svc "$SUPABASE_POSTGRES_SERVICE" >/dev/null 2>&1; then
|
|
supabase_pg_exists=1
|
|
supabase_pg_type=$(kubectl -n "$SUPABASE_NAMESPACE" get svc "$SUPABASE_POSTGRES_SERVICE" -o jsonpath='{.spec.type}' 2>/dev/null || true)
|
|
fi
|
|
|
|
if [[ "$supabase_pg_exists" -eq 1 && "$supabase_pg_type" != "ExternalName" ]]; then
|
|
log "Replacing service $SUPABASE_NAMESPACE/$SUPABASE_POSTGRES_SERVICE with ExternalName on ${SUPABASE_POSTGRES_PORT}"
|
|
kubectl -n "$SUPABASE_NAMESPACE" delete svc "$SUPABASE_POSTGRES_SERVICE" --ignore-not-found >/dev/null 2>&1 || true
|
|
supabase_pg_exists=0
|
|
fi
|
|
|
|
log "Ensuring $SUPABASE_NAMESPACE/$SUPABASE_POSTGRES_SERVICE uses port ${SUPABASE_POSTGRES_PORT}"
|
|
cat <<EOF | kubectl apply -f -
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: ${SUPABASE_POSTGRES_SERVICE}
|
|
namespace: ${SUPABASE_NAMESPACE}
|
|
labels:
|
|
app: supabase-postgres
|
|
spec:
|
|
type: ExternalName
|
|
externalName: ${DESIRED_EXTERNAL}
|
|
ports:
|
|
- name: postgres
|
|
port: ${SUPABASE_POSTGRES_PORT}
|
|
targetPort: ${DB_PORT}
|
|
EOF
|
|
|
|
if [[ "$namespace_changed" -eq 1 && "$RESTART_ON_CHANGE" -eq 1 ]]; then
|
|
restart_supabase
|
|
fi
|
|
|
|
log "Supabase port wiring complete."
|