Ingress-nginx: Unable to expose service running on different ports other than 80,443

Created on 30 Sep 2017  Â·  4Comments  Â·  Source: kubernetes/ingress-nginx

Hello,

I am trying to expose my database connection on subdomain db.[domain].com on default postgres port 5432. But after many hours of trying everything I can think of I am still unable to do it. Every tutorial/issue/article is only showing exposing services on 80/443 ports which works for me as it should. But exposing db connection seems impossible 😞 . I am always getting

psql: could not connect to server: Connection refused
        Is the server running on host "db.domain.com" (domain_ip) and accepting
        TCP/IP connections on port 5432?

Could somebody go through my minimal example here and check for mistakes please?

I am running kubernetes on GKE. It is not firewall related even when I create this rule problem remains.

image

Some logs

image

image

Most helpful comment

Closing. Ingress just exposes port 80 and 443. To expose your postgres service you just need to create a service type=LoadBalancer.

` apiVersion: v1 kind: Service metadata: name: db-svc spec: type: LoadBalancer ports: - port: 5432 targetPort: 5432 protocol: TCP selector: name: postgres

All 4 comments

Closing. Ingress just exposes port 80 and 443. To expose your postgres service you just need to create a service type=LoadBalancer.

` apiVersion: v1 kind: Service metadata: name: db-svc spec: type: LoadBalancer ports: - port: 5432 targetPort: 5432 protocol: TCP selector: name: postgres

@aledbf Thanks for response I didn't know it exposes just 80 443. I am aware of service of type LoadBalancer but I would like to avoid having two LBs. Is there a solution where I could have one LB and have externally reachable url like db.domain.com? I am new to this and google is not helping.

@kolpav you can create both services with type=NodePort and then use the gke web to create the load balancer manually.

Hi Pavel, contact me on my personal email and we can discuss this if you
want (guessing by your name, we can switch to czech language :-))

On Sat, Sep 30, 2017, 19:31 Pavel Kolář notifications@github.com wrote:

@aledbf https://github.com/aledbf Thanks for response I didn't know it
exposes just 80 443. I am aware of service of type LoadBalancer but I would
like to avoid having two LBs. Is there a solution where I could have one LB
and have externally reachable url like db.domain.com? I am new to this
and google is not helping.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/kubernetes/ingress/issues/1449#issuecomment-333323600,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADh6tUpMZnVJEz02NR-nCqc3v0hS-0cks5snnrZgaJpZM4PpmBV
.

Was this page helpful?
0 / 5 - 0 ratings