Adding Custom Header in the outgoing requests from a VirtualService in Istio

563 Views Asked by At

I have a Virtual Service for an application. And my requirement is to add a customer header in the outgoing requests from this app pod. I can't/don't want to change the application code, that's why I'm looking for the solution on k8s istio level. My virtual service code is as follows, I tried to use "Headers" but did not work.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
  name: example-vs
  namespace: example
spec:
  gateways:
    - istio-system/example-external
    - istio-system/example-internal
  hosts:
    - example.staging.internal
  http:
    - headers:
        response:
          add:
            x-custom-tenant: custom-header-testing
      match:
        - uri:
            prefix: /required-prefix
      name: required-routes
      route:
        - destination:
            host: example.xxxxx.svc.cluster.local
            port:
              number: 8080

Now I'm trying to call another service from this service, but not getting the custom header added in the above code.

Could someone pls point me in the right direction, What am I doing wrong here.

PS: I don't want to use Envoy Filter, because of the larger service mesh limitations

I tried to add a custom header in the outgoing request from the app, but did not get it

1

There are 1 best solutions below

2
peterj On

If I understand correctly, you're trying to propagate headers from service A to service B (e.g., you call service A with "custom-header: blah", service A calls service B and you want service B to receive that header).

You won't be able to do this without modifying the code - just like one has to propagate the distributed tracing headers in Istio, you'd have to do the same for your custom header.