mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 11:03:59 +00:00
- Updated `init_kong.sh` to handle `include_gitea_host` flag for improved flexibility in Gitea ingress setup. - Added comprehensive post-deploy endpoint summary in `deploy.sh` to display public services and external IPs. - Enhanced kubectl command handling with role-specific context logic for better split-cluster support. - Improved DB context logging across CNPG operations and milestones. - Updated GKE configuration with new contexts and Grafana hostname.
81 lines
3.0 KiB
Bash
Executable File
81 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
CONFIG_PATH="${PROLE_DEPLOY_CFG:-${ROOT_DIR}/conf/gke.cfg}"
|
|
|
|
if [[ -x "${ROOT_DIR}/.venv/bin/python3" ]]; then
|
|
PYTHON_BIN="${ROOT_DIR}/.venv/bin/python3"
|
|
elif [[ -x "${ROOT_DIR}/bin/python3" ]]; then
|
|
PYTHON_BIN="${ROOT_DIR}/bin/python3"
|
|
else
|
|
PYTHON_BIN="${PYTHON:-python3}"
|
|
fi
|
|
|
|
"${PYTHON_BIN}" -m prole.deploy_pipeline --config "${CONFIG_PATH}" "$@"
|
|
|
|
# Post-deploy summary
|
|
echo ""
|
|
echo "Public Endpoints:"
|
|
"${PYTHON_BIN}" - "${CONFIG_PATH}" <<'PY'
|
|
import sys
|
|
import subprocess
|
|
import json
|
|
import configparser
|
|
|
|
def get_config(path):
|
|
c = configparser.ConfigParser()
|
|
c.read(path)
|
|
# Check [Global] then [env_setup] then [init_cluster] for contexts
|
|
g = c["Global"] if "Global" in c else {}
|
|
e = c["env_setup"] if "env_setup" in c else {}
|
|
i = c["init_cluster"] if "init_cluster" in c else {}
|
|
|
|
app_ctx = g.get("APP_CLUSTER_KUBECONTEXT") or e.get("APP_CLUSTER_KUBECONTEXT") or i.get("app_cluster_kubecontext", "")
|
|
db_ctx = g.get("DB_CLUSTER_KUBECONTEXT") or e.get("DB_CLUSTER_KUBECONTEXT") or i.get("db_cluster_kubecontext", "")
|
|
return app_ctx, db_ctx
|
|
|
|
def get_ip(host, ctx):
|
|
if not ctx: return "pending"
|
|
# Try Ingress first
|
|
try:
|
|
out = subprocess.check_output(["kubectl", "--context", ctx, "get", "ingress", "-A", "-o", "json"], stderr=subprocess.DEVNULL, text=True)
|
|
items = json.loads(out).get("items", [])
|
|
for item in items:
|
|
for rule in item.get("spec", {}).get("rules", []):
|
|
if rule.get("host") == host:
|
|
ing = item.get("status", {}).get("loadBalancer", {}).get("ingress", [])
|
|
if ing: return ing[0].get("ip") or ing[0].get("hostname") or "pending"
|
|
except: pass
|
|
|
|
# Try Service fallback
|
|
try:
|
|
svcs = []
|
|
if "git" in host: svcs = [("gitlab", "gitlab-nginx-ingress-controller")]
|
|
elif "api.knoe" in host or "svc.knoe" in host: svcs = [("knoe-system", "knoe-svc-kong-proxy")]
|
|
elif "0.knoe" in host: svcs = [("supabase", "kong"), ("supabase", "studio")]
|
|
|
|
for ns, name in svcs:
|
|
out = subprocess.check_output(["kubectl", "--context", ctx, "get", "svc", "-n", ns, name, "-o", "json"], stderr=subprocess.DEVNULL, text=True)
|
|
ing = json.loads(out).get("status", {}).get("loadBalancer", {}).get("ingress", [])
|
|
if ing: return ing[0].get("ip") or ing[0].get("hostname") or "pending"
|
|
except: pass
|
|
return "pending"
|
|
|
|
app_ctx, db_ctx = get_config(sys.argv[1])
|
|
|
|
endpoints = [
|
|
("api.knoe.dev", "knoe-svc-kong", "APP", app_ctx),
|
|
("git.knoe.dev", "GitLab", "APP", app_ctx),
|
|
("db.0.knoe.dev", "Supabase Studio", "DB", db_ctx),
|
|
("api.0.knoe.dev", "Supabase Kong", "DB", db_ctx),
|
|
("svc.knoe.dev", "Grafana", "APP", app_ctx),
|
|
]
|
|
|
|
print(f"{'hostname':<20} {'service':<20} {'cluster':<10} {'external IP':<15}")
|
|
print("-" * 70)
|
|
for host, svc, clus, ctx in endpoints:
|
|
ip = get_ip(host, ctx)
|
|
print(f"{host:<20} {svc:<20} {clus:<10} {ip:<15}")
|
|
PY
|