0

I have a virtual service yaml file with below lines.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nodeserver
spec:
  hosts:
  - "*"
  gateways:
  - node-gateway
  http:
  - match:
    - uri:
        exact: /
    - uri:
        exact: /sample1
    - uri:
        exact: /sample2
    route:
    - destination:
        host: node-service
        port:
          number: 8080

Here, Instead of /sample1 and /sample2 as two url matches, can I assign something like * to route all traffic to node-service by default? Also, if the webpage has hyperlinks inside it will Istio redirect them by default or need to add any custom configuration for that?

Jonas
  • 1,147
  • 5
  • 17
  • 31
uday
  • 257
  • 2
  • 21

1 Answers1

0

You can use regex instead of exact in HTTPMatchRequest.
That way you can catch all with ECMAscript style regex.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nodeserver
spec:
  hosts:
  - "*"
  gateways:
  - node-gateway
  http:
  - match:
    - uri:
        regex: '.+'
    route:
    - destination:
        host: node-service
        port:
          number: 8080
p10l
  • 386
  • 1
  • 7
  • Thank you I will test that and reply back. Also, is there any way to set /page1 as default so that even if user types only istio gateway then it should route the traffic to /page1 also. – uday Jul 19 '21 at 08:28
  • You can use [HTTPRedirect](https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRedirect) or [HTTPRewrite](https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRewrite) to do that. This is however another question, and if you want a complete solution, you should post new question. – p10l Jul 21 '21 at 12:15