Doesn't Virtualservice for internal service cause loop?

3/1/2021

When it comes to virtualservice for internal service (without gateway spec),

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: frontend
spec:
  hosts:
  - nginx.default.svc.cluster.local
  - httpd.default.svc.cluster.local
  http:
  - name: nginx
    match:
    - uri:
        prefix: /nginx
    rewrite:
      uri: /
    route:
    - destination:
        host: nginx.default.svc.cluster.local
        port:
          number: 80
  - name: httpd
    match:
    - uri:
        prefix: /httpd
    rewrite:
      uri: /
    route:
    - destination:
        host: httpd.default.svc.cluster.local
        port:
          number: 80

This virtualservice sends traffics according to URI /nginx or /httpd,

For example, curl httpd/httpd and curl nginx/httpd will be sent to httpd server. The sequences will be.. check Hosts in spec and matching against URI will be followed.

However, after that, when the traffic is destined to the final host, the virtualservice is not considered again?

Because the virtualservice is about nginx and httpd service and when the sequence of the virtualservice is ended, the final destination is the same with hosts in spec.

When exactly a virtualservice is considered? Every moment or not when traffic is sent to hosts pertaining to hosts in virtualservice.

-- Solsupungi
istio
kubernetes

0 Answers