mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 10:13:58 +00:00
- knoe-db.yaml: switch to CNPG-managed TLS cert with serverAltDNSNames (pg.prole.org + knoe-db-rw cluster service) — removes static serverTLSSecret/serverCASecret - dns.yml: add pg.prole.org A record to prole_k3s_dns_records (10.0.0.3, 10.0.0.6) for Ansible-managed split-horizon DNS via Samba AD DC - k3s.cfg: align KNOE_HOME paths to ~/dev/prole, add PROLE_KDC_* vars, remove hardcoded KUBECTL_CONTEXT (kubeconfig current-context is authoritative) - prod.cfg: add PROLE_KDC_STORAGE_CLASS = prole-iscsi - onepassword.py: skip vault check gracefully when no 1Password session active (non-TTY) - CLAUDE.md: document production postgres connection string and DNS/CA cert ops Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
137 lines
5.1 KiB
YAML
137 lines
5.1 KiB
YAML
apiVersion: postgresql.cnpg.io/v1
|
|
kind: Cluster
|
|
metadata:
|
|
name: knoe-db
|
|
spec:
|
|
instances: 3
|
|
enablePDB: false
|
|
imageName: ${KNOE_IMAGE_REGISTRY}/knoe-db:${KNOE_DB_IMAGE_TAG}
|
|
postgresUID: 100
|
|
postgresGID: 101
|
|
maxSyncReplicas: 0
|
|
affinity:
|
|
# CloudNativePG uses its own affinity schema (not corev1.Affinity). See: `kubectl explain cluster.spec.affinity`
|
|
enablePodAntiAffinity: true
|
|
podAntiAffinityType: preferred
|
|
topologyKey: kubernetes.io/hostname
|
|
tolerations:
|
|
- key: "node-role.kubernetes.io/control-plane"
|
|
operator: "Exists"
|
|
effect: "NoSchedule"
|
|
- key: "node-role.kubernetes.io/master"
|
|
operator: "Exists"
|
|
effect: "NoSchedule"
|
|
nodeAffinity:
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
nodeSelectorTerms:
|
|
- matchExpressions:
|
|
- key: node.kubernetes.io/instance-type
|
|
operator: In
|
|
values:
|
|
- k3s
|
|
|
|
postgresql:
|
|
parameters:
|
|
shared_buffers: 256MB
|
|
pg_stat_statements.max: '10000'
|
|
pg_stat_statements.track: all
|
|
shared_preload_libraries:
|
|
- pg_stat_statements
|
|
- pg_tde
|
|
pg_hba:
|
|
# allow password access from remote hosts if environment is "#dev"
|
|
- local all postgres trust
|
|
- local all knoe scram-sha-256
|
|
- host all postgres all scram-sha-256
|
|
- host knoe knoe-db all scram-sha-256
|
|
- host all all all scram-sha-256
|
|
- hostssl knoe knoe-db all scram-sha-256
|
|
# - host all all all gss include_realm=1 krb_realm=EXAMPLE.COM
|
|
|
|
bootstrap:
|
|
initdb:
|
|
database: knoe-db
|
|
owner: knoe
|
|
localeCollate: 'en_US.utf8'
|
|
localeCType: 'en_US.utf8'
|
|
secret:
|
|
name: knoe-db-user
|
|
postInitTemplateSQL:
|
|
# Supabase convention: relocatable extensions live in `extensions`,
|
|
# not `public`. Studio's Database Advisor flags `public.pg_stat_statements`
|
|
# as a Security warning on the dashboard.
|
|
- CREATE SCHEMA IF NOT EXISTS extensions;
|
|
- CREATE EXTENSION IF NOT EXISTS pg_stat_statements SCHEMA extensions;
|
|
postInitSQL:
|
|
- DO $$ BEGIN IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'knoe') THEN CREATE ROLE knoe LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT; END IF; END $$;
|
|
- DO $$ DECLARE owner_password text; BEGIN SELECT rolpassword INTO owner_password FROM pg_authid WHERE rolname = 'knoe'; IF owner_password IS NOT NULL THEN EXECUTE format('ALTER ROLE knoe PASSWORD %L', owner_password); END IF; END $$;
|
|
- DO $$ BEGIN IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'knoe_catalog_executor') THEN CREATE ROLE knoe_catalog_executor NOLOGIN; END IF; END $$;
|
|
- CREATE SCHEMA IF NOT EXISTS knoe AUTHORIZATION knoe;
|
|
- ALTER SCHEMA knoe OWNER TO knoe;
|
|
- REVOKE ALL ON SCHEMA knoe FROM PUBLIC;
|
|
- ALTER ROLE knoe SET search_path TO knoe, public;
|
|
- CREATE EXTENSION IF NOT EXISTS pg_tde SCHEMA knoe;
|
|
- CREATE EXTENSION IF NOT EXISTS pgcrypto SCHEMA knoe;
|
|
- CREATE EXTENSION IF NOT EXISTS postgis SCHEMA knoe;
|
|
- CREATE EXTENSION IF NOT EXISTS postgis_topology SCHEMA knoe;
|
|
- CREATE EXTENSION IF NOT EXISTS vector SCHEMA knoe;
|
|
- CREATE EXTENSION IF NOT EXISTS tds_fdw SCHEMA knoe;
|
|
- GRANT USAGE ON SCHEMA knoe TO knoe;
|
|
- GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA knoe TO knoe;
|
|
- GRANT USAGE ON SCHEMA knoe TO knoe_catalog_executor;
|
|
- GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA knoe TO knoe_catalog_executor;
|
|
- ALTER DEFAULT PRIVILEGES FOR ROLE knoe IN SCHEMA knoe GRANT EXECUTE ON FUNCTIONS TO knoe_catalog_executor;
|
|
- GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA topology TO knoe;
|
|
- CREATE SCHEMA IF NOT EXISTS storage;
|
|
- CREATE SCHEMA IF NOT EXISTS graphql_public;
|
|
- DO $$ BEGIN IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'anon') THEN CREATE ROLE anon NOLOGIN; END IF; END $$;
|
|
- DO $$ BEGIN IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'authenticator') THEN CREATE ROLE authenticator LOGIN; END IF; END $$;
|
|
- GRANT USAGE ON SCHEMA public TO anon;
|
|
- GRANT USAGE ON SCHEMA storage TO anon;
|
|
- GRANT USAGE ON SCHEMA graphql_public TO anon;
|
|
- GRANT anon TO authenticator;
|
|
|
|
certificates:
|
|
serverAltDNSNames:
|
|
- pg.prole.org
|
|
- knoe-db-rw.knoe-db.svc.cluster.local
|
|
|
|
enableSuperuserAccess: true
|
|
env:
|
|
- name: AWS_REGION
|
|
value: garage
|
|
- name: AWS_DEFAULT_REGION
|
|
value: garage
|
|
|
|
storage:
|
|
size: 1Gi
|
|
pvcTemplate:
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
resources:
|
|
requests:
|
|
storage: 1Gi
|
|
storageClassName: synology-iscsi
|
|
selector:
|
|
matchLabels:
|
|
synology.storage/role: data
|
|
walStorage:
|
|
size: 1Gi
|
|
pvcTemplate:
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
resources:
|
|
requests:
|
|
storage: 1Gi
|
|
storageClassName: synology-iscsi
|
|
selector:
|
|
matchLabels:
|
|
synology.storage/role: wal
|
|
plugins:
|
|
- name: barman-cloud.cloudnative-pg.io
|
|
parameters:
|
|
barmanObjectName: knoe-db-barman-objectstore
|
|
|
|
monitoring:
|
|
enablePodMonitor: false
|