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,187
  • 5
  • 19
  • 33
uday
  • 352
  • 10
  • 30

2 Answers2

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
  • 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. –  Jul 21 '21 at 12:15
0

Use prefix: ''

This worked for me:

  http:
  - match:
      - uri:
          prefix: ''
Peter L
  • 101
  • 1