2

I'm trying to implement some sort of traffic routing using Istio in a Kubernetes cluster.

The situattion is the following one:

(customer service) => (preference service) => (recommendation service) which has two versions: v1 and v2.

I want to use a custom header, for example X-Svc-Env from an Istio VirtualService and to specify through this header the version of the Recommendation Service which I want to hit.

The configuration for the VirtualService is the following one:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: recommendation
  namespace: online
spec:
  hosts:
  - recommendation
  http:
  - match:
    - headers:
        x-svc-env:
          regex: v2
    route:
    - destination:
        host: recommendation
        subset: version-v2
  - route:
    - destination:
        host: recommendation
        subset: version-v1

Also, the DestinationRule that it's being used is the following one:

kind: DestinationRule
metadata:
  name: recommendation
  namespace: online
spec:
  host: recommendation
  subsets:
  - labels:
      version: v1
    name: version-v1
  - labels:
      version: v2
    name: version-v2

Well... this is not working because somehow, my custom header is not propagated through Envoy Proxy (I suppose).

I should mention that if I am using a well-known HTTP header, eg: baggage-user-agent (which is the User-Agent header from the OpenTracing specification, all the things are going pretty well).

Tx!

Dina Bogdan
  • 4,345
  • 5
  • 27
  • 56
  • Any specific issues/errors you occurs? I used my old example from [here](https://stackoverflow.com/questions/59238614/how-to-get-an-istio-virtualservice-to-vary-routes-by-header-along-with-uri/59309172#59309172) and everything worked, it redirect me to v1 of the pod if there is a header and if there is no header it goes to v2 of the pod. Could you try use my example and check if that works for you? – Jakub Mar 27 '20 at 07:30
  • No errors occurs. The traffic it's routed to the same pod even if I set the specified header on the request. I already tried with an example where the header was baggage-user-agent, which is a header from OpenTracing and that one works fine. I read a little about Envoy proxy, and it seems that Envoy it's doing a sanitization of the headers when the request goes through it. I think that this is the problem. – Dina Bogdan Mar 27 '20 at 07:39
  • That's why I asked to make this quick example to check if it's your cluster or your example, I think a header from OpenTracing and a custom header might have some differences, and you want the custom one which I have made and tested and it worked fine with the curl. Maybe another [string match](https://istio.io/docs/reference/config/networking/virtual-service/#StringMatch) could help, unless you need regex for that? – Jakub Mar 27 '20 at 07:48
  • I have tried with exact match as well, but without success. I think that the header is not propagated at all. – Dina Bogdan Mar 27 '20 at 08:01

0 Answers0