mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 10:13:58 +00:00
Summary: Removed the prole-db-manager microservice and simplified deployment to use prole-authority as the internal management and authorization point. Fixed two blocking bugs that prevented silent install from completing on knoe-dev-cluster. Removed: prole-db-manager - Deleted db-manager-deployment.yaml and db-manager-service.yaml from opentofu manifests - Deleted src/db-manager/ (Dockerfile, server.js, package.json, tests) - Removed prole-db-manager port-forward mapping from installer/core/env.py - Removed init_db_manager.sh from Initialization Scripts (milestones.py, actions.py) - Removed init_certmgr.sh and init_db_manager.sh tabs from services screen (services.py) - Removed live k8s Deployment/Service from knoe-dev-cluster Fixed: PostgreSQL version downgrade error (pg17 -> pg18) - Created conf/postgresql/.version with value 18 - Updated k8s/prole/prole-db.yaml and prole-db-recovery.yaml.tpl imageName to prole-db:18-089 - Fixed _init_database_options_state() to restore saved version_type from prole.cfg so db_version_type defaults to v18 (pg18) instead of silently reverting to pg17 - Added database_options.* keys to _collect_input_snapshot() in cfg.py so distribution, version_type, and all extension toggles persist to prole.cfg Fixed: Cluster name inconsistency - Removed stale prole-dev-cluster references; all scripts now use knoe-dev-cluster - Added knoe-dev-cluster to mode-detection case in etc/prole_cfg.sh Config: conf/prole.cfg - Set kerberos_config.enabled = False, KERBEROS_AUTO_ENABLED = False - Added database_options.distribution = percona, version_type = v18 - Added all 13 extension flags set to True (postgis, pgvector, pgcrypto, pgaudit, pg_repack, pg_stat_statements, pg_buffercache, pg_freespacemap, pgrowlocks, postgres_fdw, dblink, pg_stat_monitor, pgbadger) Verification: ./install.py -s -l -v -c conf/prole.cfg completed successfully. CNPG deployed prole-db:18-089 to knoe-dev-cluster; all milestones passed. Co-authored-by: Junie <junie@jetbrains.com>
185 lines
4.8 KiB
Bash
Executable File
185 lines
4.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# init_kong.sh
|
|
# Purpose:
|
|
# - Deploy Kong API Gateway (DB-less) into the service namespace
|
|
# - Replaces the prole nginx deployment as the API endpoint
|
|
# - Routes /backup/* to prole-db-manager
|
|
# - Creates the kong declarative config as a ConfigMap
|
|
# - Applies the kong deployment and service manifests
|
|
# - Provides start/stop/status/restart actions
|
|
|
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
# Shared option parsing for common core scripts
|
|
# shellcheck disable=SC1090
|
|
source "$SCRIPT_DIR/common_core_lib.sh"
|
|
|
|
# Inject default config if not provided
|
|
_has_config=0
|
|
for _arg in "$@"; do
|
|
[[ "$_arg" == "-c" || "$_arg" == "--config" || "$_arg" == -c=* || "$_arg" == --config=* ]] && _has_config=1
|
|
done
|
|
if [[ $_has_config -eq 0 && -f "$SCRIPT_DIR/../conf/prole.cfg" ]]; then
|
|
set -- "-c" "$SCRIPT_DIR/../conf/prole.cfg" "$@"
|
|
fi
|
|
unset _has_config _arg
|
|
|
|
common_core_preparse_config "$@"
|
|
|
|
# shellcheck disable=SC1090
|
|
source "$SCRIPT_DIR/prole_cfg.sh"
|
|
|
|
set -- "${COMMON_CORE_ARGS[@]}"
|
|
common_core_parse_args "$@"
|
|
|
|
if [[ -z "${PROLE_MODE:-}" ]]; then
|
|
export PROLE_MODE="k3s"
|
|
fi
|
|
|
|
if [[ "${COMMON_CORE_HELP:-0}" == 1 ]]; then
|
|
common_core_usage "$0"
|
|
exit 0
|
|
fi
|
|
|
|
if [[ -n "${COMMON_CORE_PARSE_ERROR:-}" ]]; then
|
|
echo "ERROR: ${COMMON_CORE_PARSE_ERROR}" >&2
|
|
common_core_usage "$0"
|
|
exit 2
|
|
fi
|
|
|
|
ACTION="$COMMON_CORE_ACTION"
|
|
NAMESPACE="$(common_core_resolve_namespace "default")"
|
|
common_core_apply_namespace "$NAMESPACE"
|
|
|
|
PROLE_HOME=${PROLE_HOME:-$(cd "$SCRIPT_DIR/.." && pwd)}
|
|
KONG_IMAGE="${KONG_IMAGE:-kong:3.9}"
|
|
KONG_NAME="${KONG_NAME:-prole-svc-kong}"
|
|
KONG_PROXY_PORT="${KONG_PROXY_PORT:-8000}"
|
|
KONG_ADMIN_PORT="${KONG_ADMIN_PORT:-8001}"
|
|
KONG_CONFIG_NAME="${KONG_CONFIG_NAME:-prole-svc-kong-config}"
|
|
|
|
# Upstream service defaults
|
|
DB_MANAGER_SERVICE="${DB_MANAGER_SERVICE:-prole-db-manager}"
|
|
DB_MANAGER_PORT="${DB_MANAGER_PORT:-80}"
|
|
|
|
usage() {
|
|
cat <<USAGE
|
|
Usage: $0 [--mode MODE] [-n NAMESPACE] [${COMMON_CORE_ACTIONS//|/|}] [-c conf/prole.cfg]
|
|
|
|
Actions:
|
|
start Create ConfigMap and deploy Kong
|
|
stop Remove Kong deployment, service, and ConfigMap
|
|
status Show Kong pod/service status
|
|
restart Restart Kong pods
|
|
update Create or update Kong resources
|
|
USAGE
|
|
exit 1
|
|
}
|
|
|
|
ensure_tools() {
|
|
for t in kubectl; 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
|
|
}
|
|
|
|
create_kong_config() {
|
|
echo "Creating/updating Kong declarative config '$KONG_CONFIG_NAME' in namespace '$NAMESPACE' ..."
|
|
|
|
local kong_yml
|
|
kong_yml=$(cat <<KONGEOF
|
|
_format_version: "3.0"
|
|
_transform: true
|
|
|
|
services:
|
|
- name: db-manager
|
|
url: http://${DB_MANAGER_SERVICE}.${NAMESPACE}.svc.cluster.local:${DB_MANAGER_PORT}
|
|
routes:
|
|
- name: backup-route
|
|
paths:
|
|
- /backup
|
|
strip_path: false
|
|
KONGEOF
|
|
)
|
|
|
|
kubectl create configmap "$KONG_CONFIG_NAME" \
|
|
--namespace="$NAMESPACE" \
|
|
--from-literal=kong.yml="$kong_yml" \
|
|
--dry-run=client -o yaml | kubectl apply -f -
|
|
|
|
echo "ConfigMap '$KONG_CONFIG_NAME' ready."
|
|
}
|
|
|
|
deploy() {
|
|
echo "Deploying $KONG_NAME to namespace '$NAMESPACE' ..."
|
|
|
|
local manifests_dir="$PROLE_HOME/deploy/opentofu/k3s/manifests/prole"
|
|
|
|
kubectl apply -f "$manifests_dir/kong-deployment.yaml" -n "$NAMESPACE"
|
|
kubectl apply -f "$manifests_dir/kong-service.yaml" -n "$NAMESPACE"
|
|
|
|
echo "Waiting for $KONG_NAME rollout ..."
|
|
kubectl rollout status deployment/"$KONG_NAME" -n "$NAMESPACE" --timeout=120s
|
|
echo "$KONG_NAME deployed successfully."
|
|
}
|
|
|
|
stop() {
|
|
echo "Removing $KONG_NAME from namespace '$NAMESPACE' ..."
|
|
kubectl delete deployment "$KONG_NAME" -n "$NAMESPACE" --ignore-not-found=true
|
|
kubectl delete service "$KONG_NAME" -n "$NAMESPACE" --ignore-not-found=true
|
|
kubectl delete configmap "$KONG_CONFIG_NAME" -n "$NAMESPACE" --ignore-not-found=true
|
|
echo "$KONG_NAME removed."
|
|
}
|
|
|
|
status() {
|
|
echo "=== $KONG_NAME pods ==="
|
|
kubectl get pods -n "$NAMESPACE" -l app="$KONG_NAME" 2>/dev/null || echo "No pods found"
|
|
echo ""
|
|
echo "=== $KONG_NAME service ==="
|
|
kubectl get svc "$KONG_NAME" -n "$NAMESPACE" 2>/dev/null || echo "No service found"
|
|
}
|
|
|
|
restart() {
|
|
echo "Restarting $KONG_NAME ..."
|
|
kubectl rollout restart deployment/"$KONG_NAME" -n "$NAMESPACE"
|
|
kubectl rollout status deployment/"$KONG_NAME" -n "$NAMESPACE" --timeout=120s
|
|
echo "$KONG_NAME restarted."
|
|
}
|
|
|
|
action_update() {
|
|
ensure_tools
|
|
ensure_namespace
|
|
create_kong_config
|
|
deploy
|
|
}
|
|
|
|
case "$ACTION" in
|
|
start|initialize|update|reload)
|
|
action_update
|
|
;;
|
|
stop)
|
|
ensure_tools
|
|
stop
|
|
;;
|
|
status)
|
|
ensure_tools
|
|
status
|
|
;;
|
|
restart)
|
|
ensure_tools
|
|
restart
|
|
;;
|
|
*)
|
|
usage
|
|
;;
|
|
esac
|