infrastructure/hammerhead/app/postgres/deploy/postgres.hcl
2021-06-06 13:40:04 +02:00

86 lines
1.7 KiB
HCL

# Example PostgreSQL job file: https://github.com/GuyBarros/nomad_jobs/blob/master/postgresSQL.nomad
job "postgres" {
datacenters = ["dc1"]
type = "service"
group "postgres" {
count = 1
volume "postgres-data" {
type = "host"
read_only = false
source = "postgres-data"
}
network {
mode = "bridge"
# port "db" {
# static = 5432
# to = 5432
# }
}
service {
name = "postgres"
port = "5432"
# check {
# name = "alive"
# type = "tcp"
# interval = "10s"
# timeout = "2s"
# }
connect {
sidecar_service {}
}
}
task "postgres" {
driver = "docker"
config {
# ports = ["db"]
image = "postgres"
}
volume_mount {
volume = "postgres-data"
destination = "/var/lib/postgresql/data"
read_only = false
}
template {
# Consul Template only works in template stanza.
# We need it to fetch secret values from Consul.
# The "env = true" parameter sets the environment with the data.
# "destination" key is required but its value doesn't matter.
data = <<EOH
POSTGRES_USER = "{{ key "secrets/postgres/user" }}"
POSTGRES_PASSWORD = "{{ key "secrets/postgres/password" }}"
EOH
destination = "secrets/env.env"
env = true
change_mode = "restart"
}
env {
PGDATA = "/var/lib/postgresql/data"
}
}
# resources {
# # cpu = 1000
# # memory = 1024
# network {
# # mbits = 10
# port "db" {
# static = 5432
# }
# }
# }
}
}