Using Gloo TCP Proxy to forward port 27017 for MongoDB access in a Kubernetes cluster.
The following Gateway spec works for forwarding all port 27017 traffic to the specified upstream.
spec:
bindAddress: '::'
bindPort: 27017
tcpGateway:
tcpHosts:
- destination:
single:
upstream:
name: default-mongodb-27017
namespace: gloo-system
name: one
useProxyProto: false
I would like to forward 27017 traffic based on hostname (for example, d.db.example.com points to the dev instance of Mongo and p.db.example.com points to the prod instance).
Is there a way to specify hostname (like in a virtual service route)?
(Note: This is for a educational simulation, and as such isn't a real "production" environment. This is why both the dev and prod instance will exist in the same Kubernetes cluster. This is also why a managed or external MongoDB solution isn't used)
As I mentioned in comments, as far as I know it´s not posibble to do in gateway,atleast I could not find anything about that in gateway documentation, but you can configure virtual services to make it work.
As mentioned in documentation there
And there
Take a look at this tutorial.
And more specifically at this example where they use 2 domains, echo.example.com and foxtrot.example.com, in your case that would be
d.db.example.comandp.db.example.comI hope this helps.