Hi! I have this job, that’s fairly simple. Everything works fine except the ingress.
Check passes fine, psql
works withing the container, logs looks fine, but I cannot connect to it from the outside.
When I’m on the host that’s running the container (or anywhere else, really) psql
just says:
# psql -h postgresql.ingress.dc1.consul -U postgres
psql: error: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
When I try telnet, I’ll get something similar:
# telnet postgresql.ingress.dc1.consul 5432
Trying xxx.xxx.xxx.xxx...
Connected to postgresql.ingress.dc1.consul.
Escape character is '^]'.
Connection closed by foreign host.
In consul, everything is green. Intentions are also set to allow.
Nomad is also green everywhere, so I have now idea where to look.
job "postgresql" {
datacenters = ["dc1"]
type = "service"
group "postgresql-ingress" {
network {
mode = "bridge"
port "inbound" {
static = 5432
to = 5432
}
}
service {
name = "postgresql-ingress"
port = "5432"
connect {
gateway {
proxy {
}
ingress {
listener {
port = 5432
protocol = "tcp"
service {
name = "postgresql"
}
}
}
}
}
}
}
group "postgresql" {
network {
mode = "bridge"
}
service {
name = "postgresql"
tags = ["db"]
port = "5432"
check {
type = "script"
name = "Check PG ready"
command = "su"
args = ["postgres", "-c", "/usr/local/bin/pg_isready"]
interval = "10s"
timeout = "1s"
task = "postgresql"
}
connect {
sidecar_service {}
}
}
task "postgresql" {
resources {
cpu = 500
memory = 500
}
template {
data = <<EOH
PGDATA="/var/lib/postgresql/data"
POSTGRES_HOST_AUTH_METHOD=trust
EOH
destination = "secrets/file.env"
env = true
}
driver = "docker"
config {
image = "postgres:12-alpine"
}
volume_mount {
volume = "data"
destination = "/var/lib/postgresql/data"
}
}
volume "data" {
type = "host"
source = "postgresql"
read_only = false
}
}
}
I’m running:
Consul v1.10.1 - 3x server&agent
Nomad v1.1.3 (8c0c8140997329136971e66e4c2337dfcf932692) - 3x server&agent
All with SSL.
Thanks for any help!