I am trying to deploy KongHQ, with a Postgres DB.
I have postgres already working with a persistent volume (host), but i cannot seem to get kong migration to interact with the postgres db.
The following is the code,
Please correct me!
job "postgres-kong-server" {
datacenters = ["dc1"]
type = "service"
group "postgres-kong-server" {
count = 1
volume "postgres" {
type = "host"
read_only = false
source = "postgres"
}
restart {
attempts = 10
interval = "5m"
delay = "25s"
mode = "delay"
}
task "postgres-kong-server" {
driver = "docker"
volume_mount {
volume = "postgres"
destination = "/var/lib/postgresql/data"
read_only = false
}
env = {
"POSTGRES_PASSWORD" = "xxxx"
"POSTGRES_DB" = "kong"
"POSTGRES_USER" = "kong"
}
config {
image = "postgres:12.2"
port_map {
db = 5432
}
}
resources {
cpu = 500
memory = 1024
network {
port "db" {
static = 5432
}
}
}
service {
name = "postgres-kong-server"
port = "db"
check {
type = "tcp"
interval = "10s"
timeout = "2s"
}
}
}
}
group "kong-server" {
count = 1
task "kong-migrations" {
driver = "docker"
env {
KONG_DATABASE = "postgres"
KONG_PG_DATABASE = "kong"
KONG_PG_HOST = "${NOMAD_ADDR_postgres_kong_server_db}"
KONG_PG_USER = "kong"
KONG_PG_PASSWORD = "xxxx"
}
config {
image = "kong:2.2-alpine"
command = "kong"
args = [
"migrations",
"bootstrap",
]
}
resources {
cpu = 500
memory = 1024
}
}
}
}
The other thing is that i want to run several commands on the database using kong to boostrap it. What would be the best approach? Create a new job and use batch?