Homelab/nomad_jobs/services/postgres/postgres.nomad.hcl

54 lines
1.1 KiB
HCL
Raw Normal View History

2024-02-06 20:59:15 +00:00
job "postgres" {
datacenters = ["dc1"]
type = "service"
group "database" {
count = 1
network {
mode = "bridge"
port "ingress" {
to = 5432
}
}
volume "postgres-data" {
type = "host"
source = "postgres"
}
service {
# Make available to other services by the 'postgres' name
name = "postgres"
port = "5432"
tags = ["traefik.enable=false"] # Hide postgres from traefik
# Make available through the consul service mesh
connect {
sidecar_service {
tags = ["traefik.enable=false"] # Hide postgres envoy from traefik
}
}
}
task "postgres" {
driver = "docker"
volume_mount {
volume = "postgres-data"
destination = "/var/lib/postgresql/data"
}
config {
image = "postgres:16.1-alpine3.19"
ports = ["ingress"]
}
env = {
"POSTGRES_USER"="op://InfraSecrets/Postgres Root/username",
"POSTGRES_PASSWORD"="op://InfraSecrets/Postgres Root/password"
}
}
}
}