mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 16:54:32 +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>
195 lines
6.1 KiB
Bash
Executable File
195 lines
6.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
# init_db_manager.sh
|
|
# Purpose:
|
|
# - Build and deploy the knoe-db-manager Node.js REST endpoint
|
|
# - Provides /backup/<cluster>/full to trigger barman full backups into Garage
|
|
# - Deploys to the knoe-db namespace; accessible via Kong endpoint /backup
|
|
# - Deploys to the current cluster (k3d or k3s) based on PROLE_MODE from conf/prole.cfg
|
|
#
|
|
# Usage:
|
|
# ./init_db_manager.sh [--mode MODE] <start|stop|status|restart|build>
|
|
|
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
# 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
|
|
|
|
ACTION=${1:-start}
|
|
NAMESPACE="${PROLE_NAMESPACE}"
|
|
PROLE_HOME=${PROLE_HOME:-$(cd "$SCRIPT_DIR/.." && pwd)}
|
|
DB_MANAGER_IMAGE=${DB_MANAGER_IMAGE:-knoe-db-manager:latest}
|
|
DB_MANAGER_NAME=${DB_MANAGER_NAME:-knoe-db-manager}
|
|
DB_MANAGER_PORT=${DB_MANAGER_PORT:-80}
|
|
DB_MANAGER_SRC=${DB_MANAGER_SRC:-$PROLE_HOME/src/db-manager}
|
|
REGISTRY=${REGISTRY:-}
|
|
|
|
usage() {
|
|
cat <<USAGE
|
|
Usage: $0 [--mode MODE] <start|stop|status|restart|build>
|
|
|
|
Actions:
|
|
start Build image and deploy db-manager to current cluster (k3d/k3s)
|
|
stop Remove db-manager deployment
|
|
status Show db-manager pod/service status
|
|
restart Restart db-manager pods
|
|
build Build the container image only
|
|
USAGE
|
|
exit 1
|
|
}
|
|
|
|
ensure_tools() {
|
|
for t in kubectl docker; do
|
|
command -v "$t" >/dev/null || { echo "Missing required tool: $t" >&2; exit 1; }
|
|
done
|
|
}
|
|
|
|
ensure_namespace() {
|
|
if ! kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then
|
|
echo "Creating namespace '$NAMESPACE' ..."
|
|
kubectl create namespace "$NAMESPACE" >/dev/null 2>&1 || true
|
|
fi
|
|
}
|
|
|
|
build_image() {
|
|
echo "Building $DB_MANAGER_IMAGE from $DB_MANAGER_SRC ..."
|
|
docker build -t "$DB_MANAGER_IMAGE" "$DB_MANAGER_SRC"
|
|
|
|
if [[ -n "$REGISTRY" ]]; then
|
|
local remote_tag="${REGISTRY}/${DB_MANAGER_IMAGE}"
|
|
echo "Pushing $remote_tag ..."
|
|
docker tag "$DB_MANAGER_IMAGE" "$remote_tag"
|
|
docker push "$remote_tag"
|
|
fi
|
|
}
|
|
|
|
import_image_k3d() {
|
|
if ! command -v k3d >/dev/null 2>&1; then
|
|
echo "WARN: k3d not available; skipping k3d image import." >&2
|
|
return 0
|
|
fi
|
|
|
|
local cluster_name="${K3D_CLUSTER_NAME:-prole-dev-cluster}"
|
|
echo "Importing $DB_MANAGER_IMAGE into k3d cluster '$cluster_name' ..."
|
|
k3d image import "$DB_MANAGER_IMAGE" -c "$cluster_name" >/dev/null 2>&1 || true
|
|
echo "Image imported to k3d cluster successfully."
|
|
}
|
|
|
|
import_image_k3s() {
|
|
# k3s: publish image to the shared registry and let nodes pull it.
|
|
if [[ -z "${REGISTRY:-}" ]]; then
|
|
local host
|
|
host="$(_prole_host_from_url "${PROLE_K3S_SERVER:-${K3S_SERVER_URL:-}}")"
|
|
if [[ -n "${host:-}" ]]; then
|
|
REGISTRY="${host}:5000"
|
|
fi
|
|
fi
|
|
|
|
if [[ -z "${REGISTRY:-}" ]]; then
|
|
echo "WARN: REGISTRY not set and PROLE_K3S_SERVER missing; cannot publish image for k3s." >&2
|
|
echo " Image must be available via a registry for k3s to pull." >&2
|
|
return 0
|
|
fi
|
|
|
|
local remote_tag="${REGISTRY}/${DB_MANAGER_IMAGE}"
|
|
echo "Publishing $remote_tag ..."
|
|
docker tag "$DB_MANAGER_IMAGE" "$remote_tag" >/dev/null 2>&1 || true
|
|
if ! docker push "$remote_tag"; then
|
|
if command -v skopeo >/dev/null 2>&1; then
|
|
echo "WARN: docker push failed; retrying with skopeo (insecure registry) ..." >&2
|
|
skopeo copy --dest-tls-verify=false "docker-daemon:${DB_MANAGER_IMAGE}" "docker://${remote_tag}"
|
|
else
|
|
echo "ERROR: docker push failed and skopeo is not available." >&2
|
|
return 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
deploy() {
|
|
echo "Deploying $DB_MANAGER_NAME to namespace '$NAMESPACE' ..."
|
|
|
|
local manifests_dir="$PROLE_HOME/deploy/opentofu/k3s/manifests/prole"
|
|
|
|
# Only deploy db-manager resources — the full kustomization includes services
|
|
# (garage, openbao, prole, etc.) that belong in the service namespace and would
|
|
# create duplicates if applied here.
|
|
kubectl apply -f "$manifests_dir/db-manager-deployment.yaml" -n "$NAMESPACE"
|
|
kubectl apply -f "$manifests_dir/db-manager-service.yaml" -n "$NAMESPACE"
|
|
|
|
# Apply cross-namespace ingresses separately (they have their own namespace metadata)
|
|
# Only apply if the target namespace already exists to avoid errors
|
|
if [[ -f "$manifests_dir/dashboard-ingress.yaml" ]] && kubectl get namespace kubernetes-dashboard >/dev/null 2>&1; then
|
|
kubectl apply -f "$manifests_dir/dashboard-ingress.yaml" || true
|
|
fi
|
|
if [[ -f "$manifests_dir/supabase-ingress.yaml" ]] && kubectl get namespace supabase >/dev/null 2>&1; then
|
|
kubectl apply -f "$manifests_dir/supabase-ingress.yaml" || true
|
|
fi
|
|
|
|
echo "Waiting for $DB_MANAGER_NAME rollout ..."
|
|
kubectl rollout status deployment/"$DB_MANAGER_NAME" -n "$NAMESPACE" --timeout=120s
|
|
echo "$DB_MANAGER_NAME deployed successfully."
|
|
}
|
|
|
|
stop() {
|
|
echo "Removing $DB_MANAGER_NAME from namespace '$NAMESPACE' ..."
|
|
kubectl delete deployment "$DB_MANAGER_NAME" -n "$NAMESPACE" --ignore-not-found=true
|
|
kubectl delete service "$DB_MANAGER_NAME" -n "$NAMESPACE" --ignore-not-found=true
|
|
echo "$DB_MANAGER_NAME removed."
|
|
}
|
|
|
|
status() {
|
|
echo "=== $DB_MANAGER_NAME pods ==="
|
|
kubectl get pods -n "$NAMESPACE" -l app="$DB_MANAGER_NAME" 2>/dev/null || echo "No pods found"
|
|
echo ""
|
|
echo "=== $DB_MANAGER_NAME service ==="
|
|
kubectl get svc "$DB_MANAGER_NAME" -n "$NAMESPACE" 2>/dev/null || echo "No service found"
|
|
}
|
|
|
|
restart() {
|
|
echo "Restarting $DB_MANAGER_NAME ..."
|
|
kubectl rollout restart deployment/"$DB_MANAGER_NAME" -n "$NAMESPACE"
|
|
kubectl rollout status deployment/"$DB_MANAGER_NAME" -n "$NAMESPACE" --timeout=120s
|
|
echo "$DB_MANAGER_NAME restarted."
|
|
}
|
|
|
|
case "$ACTION" in
|
|
start)
|
|
ensure_tools
|
|
ensure_namespace
|
|
build_image
|
|
case "${PROLE_MODE:-k3d}" in
|
|
k3d) import_image_k3d ;;
|
|
k3s) import_image_k3s ;;
|
|
*) echo "WARN: Unknown mode '${PROLE_MODE:-}'; skipping image import." >&2 ;;
|
|
esac
|
|
deploy
|
|
;;
|
|
stop)
|
|
ensure_tools
|
|
stop
|
|
;;
|
|
status)
|
|
ensure_tools
|
|
status
|
|
;;
|
|
restart)
|
|
ensure_tools
|
|
restart
|
|
;;
|
|
build)
|
|
ensure_tools
|
|
build_image
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|