infrastructure/hammerhead/app/postgres/deploy/postgres.hcl

86 lines
1.7 KiB
HCL
Raw Normal View History

2021-06-05 06:58:36 +00:00
# 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 {
2021-06-06 11:40:04 +00:00
mode = "bridge"
# port "db" {
# static = 5432
# to = 5432
# }
2021-06-05 06:58:36 +00:00
}
service {
name = "postgres"
2021-06-06 11:40:04 +00:00
port = "5432"
# check {
# name = "alive"
# type = "tcp"
# interval = "10s"
# timeout = "2s"
# }
2021-06-05 06:58:36 +00:00
2021-06-06 11:40:04 +00:00
connect {
sidecar_service {}
2021-06-05 06:58:36 +00:00
}
}
task "postgres" {
driver = "docker"
config {
2021-06-06 11:40:04 +00:00
# ports = ["db"]
2021-06-05 06:58:36 +00:00
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
2021-06-06 11:40:04 +00:00
destination = "secrets/env.env"
2021-06-05 06:58:36 +00:00
env = true
change_mode = "restart"
}
env {
PGDATA = "/var/lib/postgresql/data"
}
}
# resources {
# # cpu = 1000
# # memory = 1024
# network {
# # mbits = 10
# port "db" {
# static = 5432
# }
# }
# }
}
}