Hai There,
i am new to nomad and trying to do some practicals i have a simple application a go http server which connects to postgres databse and handles ‘/’ route it takes all db configs as ENV .
i configured most of my nomad file from a demo app at github.com/schmichael/django-nomadrepo but the application cannot connect to database!
my real question is what should the host be ? is it localhost or the name of the service (in my case postgres-con) ps: i tried both i am unable to connect postgres-con says host not found and localhost/127.0.0.1 says its unable to connect to db as 5432 is not open …
I am pasting my nomad config below
job "deploy2" {
datacenters = ["dc1"]
group "server" {
count = 1
network {
mode = "bridge"
port "http" {
static = 8090
}
}
service {
name = "server"
port = "http"
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "postgres-con"
local_bind_port = 5432
}
}
}
}
}
task "backendserver" {
driver = "docker"
config {
image = "charithreddyv/go-http-server"
ports = ["http"]
}
env {
DB_USER = "postgres"
DB_HOST = "127.0.0.1"
DN_PASS = "postgres"
DB_NAME = "postgres"
DB_PORT = 5432
}
}
}
group "database" {
count = 1
network {
mode = "bridge"
port "db" {
static = 5432
}
}
service {
name = "postgres-con"
port = "db"
connect {
sidecar_service {}
}
}
task "postgres" {
driver = "docker"
config {
image = "postgres"
ports = ["db"]
}
env {
POSTGRES_PASSWORD = "postgres"
}
}
}
}
i am running nomad and consul with as root user and agent -dev
Thanks on advance