mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 16:44: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>
175 lines
5.9 KiB
Bash
175 lines
5.9 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
PROG="init_gitlab"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# shellcheck disable=SC1090
|
|
source "$SCRIPT_DIR/prole_cfg.sh"
|
|
|
|
MODE="$(prole_normalize_mode "${PROLE_MODE:-${DEPLOYMENT_MODE:-k3d}}")"
|
|
NAMESPACE="${GITLAB_NAMESPACE:-}"
|
|
CFG_PATH=""
|
|
FORCE=0
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Usage:
|
|
$PROG [options] [deploy]
|
|
|
|
Options:
|
|
--mode <k3d|k3s|k8s|local> Deployment mode (default: ${MODE:-k3d})
|
|
-n, --namespace <name> Target namespace (default: gitlab)
|
|
-c, --config <prole.cfg> Path to prole.cfg (defaults to detected)
|
|
--force Uninstall existing GitLab release before deploy
|
|
--help Show this help
|
|
|
|
Behavior:
|
|
- Installs self-hosted GitLab via the official Helm chart.
|
|
- Uses CloudNativePG (CNPG) Postgres as the database backend (external DB).
|
|
EOF
|
|
}
|
|
|
|
die() { echo "[ERROR] $*" >&2; exit 2; }
|
|
log() { echo "[INFO] $*"; }
|
|
warn() { echo "[WARN] $*" >&2; }
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--mode) MODE="$(prole_normalize_mode "${2:-}")"; shift 2 ;;
|
|
--mode=*) MODE="$(prole_normalize_mode "${1#*=}")"; shift 1 ;;
|
|
-n|--namespace) NAMESPACE="${2:-}"; shift 2 ;;
|
|
--namespace=*) NAMESPACE="${1#*=}"; shift 1 ;;
|
|
-c|--config) CFG_PATH="${2:-}"; shift 2 ;;
|
|
--config=*) CFG_PATH="${1#*=}"; shift 1 ;;
|
|
--force) FORCE=1; shift 1 ;;
|
|
-h|--help) usage; exit 0 ;;
|
|
*) break ;;
|
|
esac
|
|
done
|
|
|
|
# Resolve config path and namespace defaults from prole.cfg when present
|
|
if [[ -z "$CFG_PATH" && -n "${PROLE_CONF:-}" && -f "${PROLE_CONF}/prole.cfg" ]]; then
|
|
CFG_PATH="${PROLE_CONF}/prole.cfg"
|
|
elif [[ -z "$CFG_PATH" && -f "$SCRIPT_DIR/../conf/prole.cfg" ]]; then
|
|
CFG_PATH="$SCRIPT_DIR/../conf/prole.cfg"
|
|
fi
|
|
|
|
if [[ -z "$NAMESPACE" && -n "$CFG_PATH" ]]; then
|
|
maybe_ns="$(_prole_cfg_extract_key "$CFG_PATH" "GITOPS_NAMESPACE")"
|
|
[[ -z "$maybe_ns" ]] && maybe_ns="$(_prole_cfg_extract_key "$CFG_PATH" "GITLAB_NAMESPACE")"
|
|
NAMESPACE="$maybe_ns"
|
|
fi
|
|
NAMESPACE="${NAMESPACE:-gitlab}"
|
|
export GITLAB_NAMESPACE="$NAMESPACE"
|
|
|
|
case "$MODE" in
|
|
k3d|k3s|k8s|local) ;;
|
|
*) die "Unsupported mode '$MODE' (use k3d, k3s, k8s, or local)" ;;
|
|
esac
|
|
export PROLE_MODE="$MODE"
|
|
|
|
command -v kubectl >/dev/null || die "kubectl not found"
|
|
command -v helm >/dev/null || die "helm not found (required for GitLab install)"
|
|
|
|
DB_NAMESPACE="${PROLE_NAMESPACE:-}"
|
|
if [[ -z "$DB_NAMESPACE" && -n "$CFG_PATH" ]]; then
|
|
DB_NAMESPACE="$(_prole_cfg_extract_key "$CFG_PATH" "NAMESPACE")"
|
|
fi
|
|
DB_NAMESPACE="${DB_NAMESPACE:-default}"
|
|
|
|
CNPG_CLUSTER_NAME="${CNPG_CLUSTER_NAME:-knoe-db}"
|
|
GITLAB_DB_NAME="${GITLAB_DB_NAME:-gitlabhq_production}"
|
|
GITLAB_DB_USER="${GITLAB_DB_USER:-gitlab}"
|
|
GITLAB_DB_PASSWORD="${GITLAB_DB_PASSWORD:-}"
|
|
if [[ -z "$GITLAB_DB_PASSWORD" ]]; then
|
|
GITLAB_DB_PASSWORD=$(LC_ALL=C tr -dc 'A-Za-z0-9' </dev/urandom 2>/dev/null | head -c 32 || true)
|
|
fi
|
|
|
|
DB_HOST="${CNPG_CLUSTER_NAME}-rw.${DB_NAMESPACE}.svc.cluster.local"
|
|
DB_PORT="${GITLAB_DB_PORT:-5432}"
|
|
|
|
kubectl get ns "$NAMESPACE" >/dev/null 2>&1 || kubectl create namespace "$NAMESPACE" >/dev/null 2>&1
|
|
|
|
ensure_db() {
|
|
local primary_pod=""
|
|
primary_pod=$(kubectl -n "$DB_NAMESPACE" get pods \
|
|
-l "cnpg.io/cluster=${CNPG_CLUSTER_NAME},role=primary" \
|
|
-o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)
|
|
if [[ -z "$primary_pod" ]]; then
|
|
primary_pod=$(kubectl -n "$DB_NAMESPACE" get pods \
|
|
-l "cnpg.io/cluster=${CNPG_CLUSTER_NAME}" \
|
|
-o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)
|
|
fi
|
|
if [[ -z "$primary_pod" ]]; then
|
|
die "Could not find CNPG pod for cluster '${CNPG_CLUSTER_NAME}' in namespace '${DB_NAMESPACE}'"
|
|
fi
|
|
|
|
log "Ensuring database '${GITLAB_DB_NAME}' and role '${GITLAB_DB_USER}' exist in CNPG cluster '${CNPG_CLUSTER_NAME}' (ns=${DB_NAMESPACE})"
|
|
|
|
kubectl -n "$DB_NAMESPACE" exec "$primary_pod" -- bash -lc "psql -v ON_ERROR_STOP=1 -U postgres -d postgres" <<SQL
|
|
DO \$\$
|
|
BEGIN
|
|
IF NOT EXISTS (SELECT 1 FROM pg_catalog.pg_roles WHERE rolname = '${GITLAB_DB_USER}') THEN
|
|
CREATE ROLE ${GITLAB_DB_USER} LOGIN PASSWORD '${GITLAB_DB_PASSWORD}';
|
|
END IF;
|
|
END
|
|
\$\$;
|
|
|
|
DO \$\$
|
|
BEGIN
|
|
IF NOT EXISTS (SELECT 1 FROM pg_database WHERE datname = '${GITLAB_DB_NAME}') THEN
|
|
CREATE DATABASE ${GITLAB_DB_NAME} OWNER ${GITLAB_DB_USER};
|
|
END IF;
|
|
END
|
|
\$\$;
|
|
SQL
|
|
|
|
kubectl -n "$NAMESPACE" create secret generic gitlab-db \
|
|
--from-literal=host="$DB_HOST" \
|
|
--from-literal=port="$DB_PORT" \
|
|
--from-literal=database="$GITLAB_DB_NAME" \
|
|
--from-literal=username="$GITLAB_DB_USER" \
|
|
--from-literal=password="$GITLAB_DB_PASSWORD" \
|
|
--dry-run=client -o yaml | kubectl apply -f - >/dev/null
|
|
}
|
|
|
|
ensure_db
|
|
|
|
RELEASE_NAME="${GITLAB_RELEASE_NAME:-gitlab}"
|
|
|
|
if [[ "$FORCE" -eq 1 ]]; then
|
|
warn "--force specified; uninstalling existing release '$RELEASE_NAME' in namespace '$NAMESPACE' (if present)"
|
|
helm -n "$NAMESPACE" uninstall "$RELEASE_NAME" >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
GITLAB_DOMAIN="${GITLAB_DOMAIN:-${DOMAIN:-${PROLE_DOMAIN:-}}}"
|
|
GITLAB_DOMAIN="${GITLAB_DOMAIN:-example.local}"
|
|
|
|
log "Adding/updating GitLab Helm repo"
|
|
helm repo add gitlab https://charts.gitlab.io/ >/dev/null 2>&1 || true
|
|
helm repo update >/dev/null
|
|
|
|
log "Installing GitLab (release=$RELEASE_NAME, ns=$NAMESPACE, domain=$GITLAB_DOMAIN)"
|
|
|
|
# Notes:
|
|
# - We keep the chart install minimal to avoid assuming ingress/cert-manager setup.
|
|
# - We disable the bundled PostgreSQL and point GitLab to CNPG.
|
|
helm upgrade --install "$RELEASE_NAME" gitlab/gitlab \
|
|
-n "$NAMESPACE" \
|
|
--timeout 30m \
|
|
--wait \
|
|
--set global.hosts.domain="$GITLAB_DOMAIN" \
|
|
--set global.hosts.https=false \
|
|
--set certmanager.install=false \
|
|
--set prometheus.install=false \
|
|
--set postgresql.install=false \
|
|
--set global.psql.host="$DB_HOST" \
|
|
--set global.psql.port="$DB_PORT" \
|
|
--set global.psql.username="$GITLAB_DB_USER" \
|
|
--set global.psql.database="$GITLAB_DB_NAME" \
|
|
--set global.psql.password.secret=gitlab-db \
|
|
--set global.psql.password.key=password
|
|
|
|
log "Done. Inspect services/pods with: kubectl -n $NAMESPACE get pods,svc"
|