mirror of
https://github.com/dredx/prole.git
synced 2026-09-27 22:44:31 +00:00
UI screens - database.py: fix mode detection to use env_key priority (prod→k8s, service→k3s) so stale DEPLOYMENT_MODE never overrides the user's chosen environment - database.py: Registry status reads ARTIFACT_REGISTRY_AVAILABLE persisted by cluster screen; uses SERVICE_NAMESPACE for Artifact Registry repo name - cluster.py: add Artifact Registry traffic light (amber→green/red) to prod section; _check_artifact_registry_async persists ARTIFACT_REGISTRY_AVAILABLE into Global cfg - cluster.py: re-trigger Artifact Registry check after GKE cluster selection so the light re-evaluates once region is available from KUBECONTEXT - cluster_nodes.py: fix TclError on Python 3.14 — pady=(2,0) tuple → pady=2 scalar - __init__.py: seed knoe-system namespace when saved value is "default", not only when empty - services.py: replace hardcoded "Prole DB" log string with dynamic cnpg_cluster name Core ops - cloudnative_pg.py: replace one-shot Barman plugin retry with 6-attempt loop; first cert-manager/x509 failure triggers rollout restart + 30 s CA propagation wait; subsequent failures back off up to 60 s per attempt - cloudnative_pg.py: TLS CA CN now uses cluster_name instead of hardcoded "Prole CNPG CA" - registry.py, garage_store.py: refactored into per-mode modules (k3d/k3s/k8s registry and garage store, shared _garage_common) Deploy / config - deploy/gcp/gke/knoe-db.yaml: GKE-specific CNPG cluster manifest (rw/ro/r on separate nodes with premium-rwo storage) - etc/init_common_services.sh, modes/k8s/knoe-db/.version: updated for current deploy - kong-deployment.yaml: updated manifest Tests - test_cluster_nodes_render_smoke.py: add pack/grid, winfo_children, winfo_reqheight, update_idletasks, grid_slaves to dummy widgets; monkeypatch tk.Label so CNPG placement render completes without a real Tkinter root Co-authored-by: Junie <junie@jetbrains.com>
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""Shared helpers for Garage object-store ops across all deployment modes."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import secrets
|
|
|
|
from ._services_common import (
|
|
_LogFn,
|
|
_exists,
|
|
_kubectl,
|
|
_log,
|
|
_to_bool,
|
|
)
|
|
|
|
|
|
def _garage_namespace(namespace: str | None, env: dict | None) -> str:
|
|
service_ns = str((env or {}).get("SERVICE_NAMESPACE") or "").strip()
|
|
if env:
|
|
explicit = str(env.get("GARAGE_NAMESPACE") or "").strip()
|
|
if explicit:
|
|
return service_ns if explicit == "default" and service_ns else explicit
|
|
|
|
raw = (namespace or "").strip() or service_ns or str((env or {}).get("NAMESPACE") or "").strip() or "knoe-system"
|
|
if raw == "default":
|
|
return service_ns or "knoe-system"
|
|
return raw
|
|
|
|
|
|
def _ensure_garage_secret(*, namespace: str, env: dict | None = None, log: _LogFn | None = None) -> None:
|
|
secret_name = str((env or {}).get("GARAGE_SECRET_NAME") or "garage-secrets").strip() or "garage-secrets"
|
|
force = _to_bool((env or {}).get("PROLE_GARAGE_FORCE_SECRET"), default=False)
|
|
if not force and _exists("secret", secret_name, namespace, env=env):
|
|
return
|
|
|
|
payload = (
|
|
"apiVersion: v1\n"
|
|
"kind: Secret\n"
|
|
"metadata:\n"
|
|
f" name: {secret_name}\n"
|
|
"type: Opaque\n"
|
|
"stringData:\n"
|
|
f" rpc_secret: {json.dumps(secrets.token_hex(32))}\n"
|
|
f" admin_token: {json.dumps(secrets.token_urlsafe(32))}\n"
|
|
f" metrics_token: {json.dumps(secrets.token_urlsafe(32))}\n"
|
|
)
|
|
_kubectl(
|
|
["-n", namespace, "apply", "-f", "-"],
|
|
env=env,
|
|
input_text=payload,
|
|
timeout=90,
|
|
check=True,
|
|
)
|
|
_log(log, f"[GARAGE] Ensured secret/{secret_name} in namespace {namespace}")
|