78 lines
1.6 KiB
HCL
78 lines
1.6 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 {
|
||
|
port "db" { static = 5432 }
|
||
|
}
|
||
|
|
||
|
service {
|
||
|
name = "postgres"
|
||
|
port = "db"
|
||
|
|
||
|
check {
|
||
|
name = "alive"
|
||
|
type = "tcp"
|
||
|
interval = "10s"
|
||
|
timeout = "2s"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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 = true
|
||
|
change_mode = "restart"
|
||
|
}
|
||
|
|
||
|
env {
|
||
|
PGDATA = "/var/lib/postgresql/data"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# resources {
|
||
|
# # cpu = 1000
|
||
|
# # memory = 1024
|
||
|
# network {
|
||
|
# # mbits = 10
|
||
|
# port "db" {
|
||
|
# static = 5432
|
||
|
# }
|
||
|
# }
|
||
|
# }
|
||
|
|
||
|
}
|
||
|
}
|