Istio - Routing of multiple react apps on a single virtual service

12/3/2019

There are 2 frontend express static react app and we are trying to route the request to those services. One of them should be available on root and other on /provider.The route to /provider is not showing the static content. Its working for / (root).

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: example-gateway
  namespace: default
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - hosts:
    - example.com     # frontend http
    port:
      name: http-example  
      number: 80
      protocol: HTTP


--- 
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: frontend-service
  namespace: default
spec:
  hosts:
  - example.com
  gateways:
  - example-gateway
  http:  
  - name: frontend-default-route
    match:
    - uri:
        exact: /
    - uri:
        prefix: /callback   
    - uri:
        prefix: /static
    - uri:
        regex: '^.*\.(ico|png|jpg)
#x27;
route: - destination: host: frontend-shopper-service.default.svc.cluster.local port: number: 9000 - name: frontend-provider-route match: - uri: prefix: /provider - uri: prefix: /provider/callback - uri: prefix: /provider/static - uri: regex: '/provider/^.*\.(ico|png|jpg)
#x27;
rewrite: uri: / route: - destination: host: frontend-provider-service.default.svc.cluster.local port: number: 9000

We believe the issue has to do with the /provider/callback, /provider/static and /provider/^.*.(ico|png|jpg)$.

-- nikhil
express
istio
kubernetes
reactjs

1 Answer

12/6/2019

Do you receive an error message like 400 or what you mean with not showing?

-- Edgar Gore
Source: StackOverflow