k8s/iam: add cloudnativepg postgres and vault + authentik

- PostgreSQL 3-replica HA with pgvector
- Vault S3 storage backend (MinIO)
- Authentik federated OIDC provider
- Vault auto-unseal via postStart hook
This commit is contained in:
Story Crater Bot
2026-07-11 19:17:22 -07:00
parent 36aea89e47
commit 674c8f0d66
20 changed files with 3047 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# Safe database initialization script
# Applies init-users.sql with environment variable substitution
# Exit on any error
set -euo pipefail
# Get superuser password from CNPG secret
PG_PASSWORD=$(kubectl get secret -n ddb ddb-cluster-app -o jsonpath='{.data.password}' | base64 -d)
export PGPASSWORD="$PG_PASSWORD"
# Apply SQL with safe variable substitution (psql -v prevents injection)
psql \
-h ddb-cluster-rw.ddb.svc.cluster.local \
-U postgres \
-d postgres \
-v authentik_password="$AUTHENTIK_PG_PASSWORD" \
-v story_crater_password="$STORY_CRATER_PG_PASSWORD" \
-f k8s/ddb/init-users.sql
unset PGPASSWORD
echo "✓ Database initialization complete"