prole/knoe-db/init_prole_app.sql
chrisfu cf33342500 feat(prole): bootstrap knoe-auth on k3s; tenant onboarding; cluster stabilisation
knoe-auth (prole.org k3s):
- Fix CNPG manifest drift: remove spec.backup.pluginConfiguration (CNPG 1.28 only),
  switch spec.certificates from serverTLSSecret to serverAltDNSNames
- Apply knoe-auth Round 1 schema + GRANTs manually (postInitSQL had never run on live cluster)
- Fix OIDC signing key generator: base64(DER) not base64(PEM) — OidcTokenService
  does Base64.decode() → PKCS8EncodedKeySpec which requires raw DER bytes
- Add OIDC controllers: authorize, token, userinfo, jwks, discovery
- Add prole Spring profile: cookieDomain, emailDomain, Kerberos config
- Add secret example templates: knoe-db-user, knoe-auth-oidc-signing, knoe-auth-google-prole
- Kong configmap: scope knoe-auth route to /auth prefix only

Tenant onboarding:
- Add etc/onboard_tenant.sh: provision/apply/rotate/status workflow backed by 1Password
  vaults; types: 'enterprise' (own Kerberos + domain) and 'tenant' (hosted, initContainer KDC)
- Provision 'Knoe Tenant - prole.org' vault; apply all 7 k8s secrets to knoe-system
- init_knoe_auth.sh: add explicit GRANT + ALTER DEFAULT PRIVILEGES for knoe role

Cluster stabilisation:
- gitea: roll back 14-day stuck rollout (RWO PVC + maxSurge=100% deadlock);
  patch deployment strategy to Recreate
- supabase: create supabase_admin role, _supabase db, _analytics schema, _realtime schema
  in CNPG — analytics and realtime had never connected since Helm install day 1
- knoe-db barman ObjectStore: add GCS-backed objectstore manifest + scheduled backup

Infrastructure:
- gandalf host_vars: k3s registry config
- pi host_vars: clean up stale entries
- knoe-db schemas: ekosystem.sql, ekosystem_objects.sql
- init_prole_app.sql: prole app DB initialisation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-26 00:50:37 -07:00

27 lines
1.1 KiB
PL/PgSQL

-- Reference init script for direct psql execution.
-- Run from the knoe-db/ directory:
-- psql -v ON_ERROR_STOP=1 -U knoe -d knoe-db -f init_prole_app.sql
--
-- CNPG path: SQL is wired via ConfigMap + postInitApplicationSQLRefs.
-- See docs/plans/junie/ekosystem-uuid-cnpg-wire.md for pending CNPG work.
-- Extensions
CREATE EXTENSION IF NOT EXISTS pgcrypto SCHEMA knoe;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA knoe TO knoe;
CREATE EXTENSION IF NOT EXISTS postgis SCHEMA knoe;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA knoe TO knoe;
CREATE EXTENSION IF NOT EXISTS postgis_topology SCHEMA knoe;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA knoe TO knoe;
CREATE EXTENSION IF NOT EXISTS vector SCHEMA knoe;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA knoe TO knoe;
CREATE EXTENSION IF NOT EXISTS tds_fdw SCHEMA knoe;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA knoe TO knoe;
-- Ekosystem UUID system (depends on extensions above)
\i schema/ekosystem.sql
\i schema/ekosystem_objects.sql
-- Seed: knoe-db is tenant 0 (inserted idempotently in ekosystem.sql)
-- Register prole as tenant 1 when deploying the prole ekosystem:
-- SELECT * FROM knoe.register_tenant('prole');