<p>I would like to route traffic to pods based on headers - with a fallback.</p>
<p>The desired result would be a k8s cluster where multiple versions of the same service could be deployed and routed to using header values.</p>
<p>svcA
svcB
svcC</p>
<p>each of these services (the main branch of git repo) would be deployed either to default namespace or labelled 'main'. any feature branch of each service can also be deployed, either into its own namespace or labelled with the branch name.</p>
<p>Ideally by setting a header <code>X-svcA</code> to a value matching a branch name, we would route any traffic to the in matching namespace or label. If there is no such name space or label, route the traffic to the default (main) pod.</p>
<pre><code>if HEADERX &amp;&amp; svcX:label 
    route-&gt;svcX:label
else
    route-&gt;svcX 
</code></pre>
<p>The first question - is this (or something like) even possible with istio or linkerd</p>

<p>You can do that using Istio <code>VirtualService</code></p>
<pre><code>apiVersion: networking.istio.io/v1beta1
kind: VirtualService
...
spec:
  hosts:
  - reviews
  http:
  - match:
    - headers:
        end-user:
          exact: jason
    route:
    - destination:
        host: reviews
        subset: v2
  - route:
    - destination:
        host: reviews
        subset: v1
</code></pre>
<p>Read more <a href="https://istio.io/latest/docs/tasks/traffic-management/request-routing/#route-based-on-user-identity" rel="nofollow noreferrer">here</a>.</p>
