Files
NomadBackup/nomad_backup/20251115_143630/postgres-15.hcl
2025-11-21 13:07:40 -08:00

117 lines
2.2 KiB
HCL

job "postgres-15" {
type = "system"
datacenters = ["dc1"]
group "group" {
count = 1
network {
port api {
static = 8008
to = 8008
}
port pg {
static = 5432
to = 5432
}
}
task "db" {
driver = "docker"
template {
data = <<EOL
scope: postgres
name: pg-{{env "node.unique.name"}}
namespace: /nomad
restapi:
listen: 0.0.0.0:8008
connect_address: {{env "attr.unique.network.ip-address"}}:8008
consul:
scheme: http
host: {{env "attr.unique.network.ip-address"}}:8500
register_service: True
bootstrap:
dcs:
ttl: 30
loop_wait: 10
retry_timeout: 10
maximum_lag_on_failover: 1048576
postgresql:
use_pg_rewind: true
use_slots: true
parameters:
timezone: 'UTC'
max_connections: 100
shared_preload_libraries: pg_stat_statements
shared_buffers: 64MB
work_mem: 16MB
effective_cache_size: 512MB
tcp_keepalives_idle: 300
timescaledb.telemetry_level: off
method: local
local:
command: /usr/local/bin/docker-initdb.sh
keep_existing_recovery_conf: True
initdb:
- encoding: UTF8
pg_hba:
- host all postgres all md5
- host replication repl all md5
- host all all all md5
users:
postgres:
password: postgres
options:
- createrole
- createdb
repl:
password: repl
options:
- replication
postgresql:
listen: 0.0.0.0:5432
connect_address: {{env "attr.unique.network.ip-address"}}:5432
use_unix_socket: true
data_dir: /store/data
authentication:
replication:
username: repl
password: repl
superuser:
username: postgres
password: postgres
EOL
destination = "/secrets/patroni.yml"
}
config {
image = "ghcr.io/sstent/nomad-pgsql-patroni:latest"
volumes = [
"/mnt/configs/postgres:/store",
]
ports = ["api", "pg"]
}
env {
PGDATA="/store/data"
// POSTGRES_USER="root"
// POSTGRES_PASSWORD="rootpassword"
}
resources {
memory = 1024
}
}
}
}