apiVersion: v1
kind: ConfigMap
metadata:
  name: postgres-config
data:
  pg_hba.conf: |
    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    local   all            all                                     trust
    host    all            all             127.0.0.1/32            trust
    host    all            all             ::1/128                 trust
    host    all            all             0.0.0.0/0               scram-sha-256
  postgresql.conf: |
    # Connection Settings
    listen_addresses = '*'
    max_connections = 100
    
    # Memory Settings
    shared_buffers = 128MB
    work_mem = 4MB
    maintenance_work_mem = 64MB
    
    # Write Ahead Log
    max_wal_size = 1GB
    min_wal_size = 80MB
    checkpoint_timeout = 5min
    checkpoint_completion_target = 0.9
    
    # Query Planner
    random_page_cost = 1.1
    effective_cache_size = 4GB
    
    # Autovacuum
    autovacuum = on
    autovacuum_max_workers = 3
    autovacuum_naptime = 1min
    autovacuum_vacuum_threshold = 50
    autovacuum_analyze_threshold = 50
    
    # Logging
    log_min_duration_statement = 1000
    log_checkpoints = on
    log_connections = on
    log_disconnections = on
    log_lock_waits = on
    log_temp_files = 0
    log_autovacuum_min_duration = 0
    
    # Other Settings
    dynamic_shared_memory_type = posix
    effective_io_concurrency = 200
    default_statistics_target = 100
    
    # Authentication
    password_encryption = scram-sha-256
    
    # Error Reporting
    log_min_error_statement = error
    log_statement = 'all' 