Istio traffic routing based on custom headers

3/26/2020

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
envoyproxy
istio
kubernetes

0 Answers