69 lines
1.2 KiB
HCL
69 lines
1.2 KiB
HCL
job "postgres" {
|
|
datacenters = ["alo"]
|
|
|
|
group "db" {
|
|
network {
|
|
port "db" {
|
|
static = 5432
|
|
}
|
|
port "exporter" {
|
|
to = 9187
|
|
}
|
|
}
|
|
|
|
task "postgres" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
image = "postgres:15-alpine"
|
|
ports = ["db"]
|
|
volumes = [ "/data/compute/appdata/postgres:/var/lib/postgresql/data" ]
|
|
}
|
|
|
|
env {
|
|
POSTGRES_PASSWORD = "${var.pg_password}"
|
|
}
|
|
|
|
service {
|
|
name = "postgres"
|
|
port = "db"
|
|
check {
|
|
type = "tcp"
|
|
port = "db"
|
|
interval = "30s"
|
|
timeout = "2s"
|
|
}
|
|
}
|
|
|
|
resources {
|
|
cpu = 1000
|
|
memory = 512
|
|
}
|
|
}
|
|
|
|
task "exporter" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
image = "quay.io/prometheuscommunity/postgres-exporter"
|
|
ports = ["exporter"]
|
|
}
|
|
|
|
env {
|
|
DATA_SOURCE_NAME = "postgresql://postgres:${var.pg_password}@${NOMAD_ADDR_db}/postgres?sslmode=disable"
|
|
}
|
|
|
|
service {
|
|
name = "postgres-exporter"
|
|
port = "exporter"
|
|
tags = ["metrics"]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
variable "pg_password" {
|
|
type = string
|
|
default = "Faelaishewohlees4nei"
|
|
}
|