<p>I am trying to set up the routes of two services in a kubernetes cluster, and I want to do a canary release of 2 different services with specific weighs.
For example: if /endpoint1 is reached then it routes 50%  of the traffic to service1, and for the other 50% I want to rewrite, then route to service2.
If I try this virtual service</p>

<pre><code>  http:
  - match:
      uri:
        exact: /path1
    rewrite:
      uri: /path1modified
    route:
    - destination:
        host: service1host
        weigh: 50
    - destination:
        host: service2host
        weigh: 50
</code></pre>

<p>it will rewrite then route with path1modified.
so I would need something like this</p>

<pre><code>  http:
  - match:
      uri:
        exact: /path1
    route:
    - destination:
        host: service1host
        weigh: 50
    - destination:
        host: service2host
        weigh: 50       
        rewrite:
          uri: /path1modified
</code></pre>

<p>I am curios if this is possible.
Thanks a lot.</p>

<p><strong>UPDATE</strong>
Thank you all for the answers given, eventually I found a way
basically I had a webapp(which used path1) and I had a service(which used modifiedPath1 in the backend, but it needed path1 in browser, use rewrite) and I wanted to weight the traffic between these 2. I tried with virtual service, but I couldn't manage to find a way to include both paths. My solution was to add a traffic manager, which sends weighted traffic to webapp and my service, then for the webapp leave the endpoints as they are, and for the service if match uri exact /path1 then rewrite to modifiedPath1.</p>

<p>There are couple of things you are not doing, I would say. First of all to do canary, you don't do it for two different services, but your do for two subsets of the same service. In the end, there are two different deployments, but you need to  define just one service, then through a <code>DestinationRule</code> you define the subsets.</p>

<p>In other words, you have two deployments right? These two deployments will have one common label, and one label that differs. Through the common labels you will define <code>DESTINATION_HOST_THAT_HAS_SUBSETS</code>, and through the labels that differs you would define the subsets <code>service1host</code> and <code>service2host</code>.</p>

<p>Then, your <code>VirtualService</code> will look like this:</p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: server-vs
spec:
  hosts:
  - DESTINATION_HOST_THAT_HAS_SUBSETS
  http:
  - match:
    - uri:
        prefix: /path1
    rewrite:
      uri: /path1modified
    route:
    - destination:
        host: DESTINATION_HOST_THAT_HAS_SUBSETS
        subset: service1host
      weight: 50
    route:
    - destination:
        host: DESTINATION_HOST_THAT_HAS_SUBSETS
        subset: service2host
      weight: 50
</code></pre>

<p><strong>UPDATE</strong></p>

<p>After jt97's comment, which is correct about being possible to have two separate services, this <code>VirtualService</code> should work as well.</p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: server-vs
spec:
  hosts:
  - DESTANTION_HOST
  http:
  - match:
    - uri:
        prefix: /path1
    rewrite:
      uri: /path1modified
    route:
    - destination:
        host: service1host
      weight: 50
    route:
    - destination:
        host: service2host
      weight: 50
</code></pre>
