Connect database by TCPIngress

Hi,

I have a mongodb deployment on my k8s cluster.

I want to expose the service via the kong tcpingress.

apiVersion: configuration.konghq.com/v1beta1
kind: TCPIngress
metadata:
  annotations:
    certmanager.k8s.io/cluster-issuer: letsencrypt-production-issuer
    kubernetes.io/ingress.class: "kong"
    nginx.ingress.kubernetes.io/use-regex: "true"
    konghq.com/strip-path: "true"
  name: ingress-mongodb
  namespace: mongodb
spec:
  rules:
    - host: HOST 
      backend:
        serviceName: mongodb-svc
        servicePort: 27017

However when I try to connect to my it I got the following response

mongo --host HOST --username mongodb-admin --password PASSWORD  --port 80
MongoDB shell version v4.4.4
connecting to: mongodb://HOST:80/?compressors=disabled&gssapiServiceName=mongodb
Error: network error while attempting to run command 'isMaster' on host 'HOST:80'  :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

I precise that when I did a port forwarding via kubectl port-forward I can connect.

I suppose that something is wrong with my TCPingress configuration, what am I missing ?

Thanks in advance

kong version : 2.1.4
kong ingress controller : 0.10.0 with  pgsql Database
1 Like

Hi, I have am experiencing this exact same problem. Can anyone of the community provide some help ?
It should be very easy to expose a mongodb or a postgreSQL database through the kong kubernetes ingress.