Route HTTP traffic based on source pod

Is it possible to route HTTP traffic based on the pod sending the traffic? Currently I am using an HTTP Header to send traffic to canary or production services. When a pod needs to target a canary deployment the code is then responsible for setting a header, normally based on an environment variable our pipeline sets. It would be great if we could somehow instruct Istio and the pod’s sidecar to send all it’s traffic to the canary pods. So canary-pod-a gets route to canary-service-b, while prod-pod-a gets routed to prod-service-b. Is it possible to route based on the sender/requester?

I’ve skimmed the docs and nothing like this popped out at me, any help is appreciated. Thanks!

1 Like

Have a look at the HTTPMatchRequest.SourceLabels

1 Like

Ahh thankyou! It’s under L4MatchAttributes in the docs for anyone who comes across this post.

This config works fine for me:

http:
   ### Canary routing
    - match:  
      - headers: # Where header is canary
          x-app-version: 
            exact: "canary"
      - sourceLabels: # ** OR ** source pod has label(s)
          environment: "canary"
      route:
      - destination:
          host: myapp.mynamespace.svc.cluster.local
          subset: "canary"
    ### Prod routing
    - route:
      - destination:
          host: myapp.mynamespace.svc.cluster.local
          subset: "prod"