kind: Gateway
apiVersion: networking.istio.io/v1alpha3
metadata:
name: postgres-gateway
namespace: istio-system
spec:
servers:
- hosts:
- db-test.example.com
- db-prod.example.com
port:
name: postgres-tcp
number: 5432
protocol: TCP
selector:
istio: ingressgateway
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
name: db-test-vs
namespace: istio-system
spec:
hosts:
- db-test.example.com
gateways:
- test-gateway
tcp:
- match:
- port: 5432
route:
- destination:
host: db-postgresql.test.svc.cluster.local
port:
number: 5432
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
name: db-prod-vs
namespace: istio-system
spec:
hosts:
- db-prod.example.com
gateways:
- test-gateway
tcp:
- match:
- port: 5432
route:
- destination:
host: db-postgresql.prd.svc.cluster.local
port:
number: 5432
If I try to connect to db, I am always connected to the same DB
psql -U postgres testdb -h test-db.example.com
psql -U postgres proddb -h prod-db.example.com
I thought host field should help to redirect to correct service.
Is anyone can suggest a correct configuration ? Is it possible ?
istioctl proxy-config listener istio-ingressgateway-8dbb57f65-4tvhb -n istio-system
ADDRESS PORT MATCH DESTINATION
0.0.0.0 5432 ALL Cluster: outbound|5432|| db-postgresql.test.svc.cluster.local
Of course one line for prod does not exist
Thank you