homelab/archive/2022.07.bxl-k3s-pi/utils/storage/postgres/config.yaml

73 lines
2.0 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: postgres
namespace: storage
data:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
PGUSER: postgres
PGDATA: "/var/lib/postgresql/data/pgdata"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-files
namespace: storage
data:
postgresql-master.conf: |
listen_addresses = '*'
port = 5432
max_connections = 100
shared_buffers = 128MB
dynamic_shared_memory_type = posix
log_timezone = 'UTC'
datestyle = 'iso, mdy'
timezone = 'UTC'
# Replication
wal_level = hot_standby
max_wal_senders = 5
# wal_keep_segments = 32
pg_hba.conf: |
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host replication replication all md5
host all all all md5
postgresql-replica.conf: |
listen_addresses = '*'
port = 5432
max_connections = 100
shared_buffers = 128MB
dynamic_shared_memory_type = posix
log_timezone = 'UTC'
datestyle = 'iso, mdy'
timezone = 'UTC'
# Replication - replica
hot_standby = on
create-replica-user.sh: |
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE ROLE replication WITH REPLICATION PASSWORD '$REPLICATION_PASSWORD' LOGIN
EOSQL