Ingress gateway tcp multiple connection

Hi,

I created a gateway and virtual service to access a postgres server. It works very well.
But it works only for one instance.
This is my configuration:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: postgres-gateway
namespace: test
spec:
selector:
istio: ingressgateway # use istio default controller
servers:

  • hosts:
    • ‘hostname1’
      port:
      number: 5432
      name: tcp-postgres
      protocol: TCP

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: postgres-vs
namespace: test
spec:
hosts:

  • “hostname1”
    gateways:
  • postgres-gateway
    hosts:
  • ‘hostname1’
    tcp:
  • match:
    • port: 5432
      route:
    • destination:
      host: postgres-test-postgresql-ha-pgpool.test.svc.cluster.local
      port:
      number: 5432

But now I have a second database running also on port 5432 and a different namespace.

How can I make it accessible with an ingress too ?

When I check the listener , I have:

istioctl pc listener -n istio-system istio-ingressgateway-56b8d79bfc-qc82n
ADDRESS PORT MATCH DESTINATION
0.0.0.0 5432 ALL Cluster: outbound|5432||postgres-test-postgresql-ha-pgpool.test.svc.cluster.local

If apply a gw, vs with different hostname and of course difference destination, the new listener is not visible.

Have you got any idea how I can configure it ?

Thank you

I believe because this is TCP traffic you do not have the luxury of routing based on SNI (i believe). you would have to use different ports within istio to differentiate the traffic.

example here routing to two different tcp services https://www.alibabacloud.com/help/doc-detail/128542.htm

sniHosts is only for TLS.

I will have a look with link.

Thank you.

ps: Would you have also an idea without using istio ?