I have 5 backend services which should be connected from a frontend service based on the tcp port. Just to abstract the frontend service from backend, I wanted to use single host name. Please note that only frontend service should be exposed using Gateway. I’m trying to achieve this using the below VirtualService definition (Started with 2 services: backend-svc1 and backend-svc2 and they are running fine)
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: backend-vs
namespace: default
spec:
hosts:
- "backend-svc1"
gateways:
- mesh
tcp:
- match:
- port: 18001
route:
- destination:
host: backend-svc1.default.svc.cluster.local
port:
number: 18001
tcp:
- match:
- port: 18002
route:
- destination:
host: backend-svc2.default.svc.cluster.local
port:
number: 18002
Using the above VirtualService, only backend-svc1 works fine, not the other one.
Next, I tried using the ServiceEntry
below:
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: backend-svc-se
namesapce: default
spec:
hosts:
- "backend-svc"
- "backend-svc.default.svc.cluster.local"
location: MESH_INTERNAL
ports:
- number: 18001
name: backend1
protocol: TCP
- number: 18002
name: backend2
protocol: TCP
resolution: NONE
endpoints:
- address: backend-svc1
ports:
tcp: 18001
- address: backend-svc2
ports:
tcp: 18002
And I accessed the backend service using backend-svc
(spec.hosts in the ServiceEntry) from my frontend service. Still no luck. Is it even possible to map multiple tcp services to a single VirtualService?
Kubernetes Version - 1.14 (Amazon EKS)
Istio Version - 1.3.0