<p>I have the following service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: downstream-service
spec:
  type: ClusterIP
  selector:
    app: downstream
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
</code></pre>

<p>which I'd like to load balance based on app version which I've defined as follows in deployments:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: downstream-deployment-v1
  labels:
    app: downstream
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: downstream
      version: v1
  template:
    metadata:
      labels:
        app: downstream
        version: v1
    spec:
      containers:
      - name: downstream
        image: downstream:0.1
        ports:
        - containerPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: downstream-deployment-v2
  labels:
    app: downstream
    version: v2
spec:
  replicas: 1
  selector:
    matchLabels:
      app: downstream
      version: v2
  template:
    metadata:
      labels:
        app: downstream
        version: v2
    spec:
      containers:
      - name: downstream
        image: downstream:0.2
        ports:
        - containerPort: 80
</code></pre>

<p>Now this routes traffic 50/50 as expected on both of those deployments but I'd like to tweak the weights as per <a href="https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRouteDestination" rel="nofollow noreferrer">https://istio.io/latest/docs/reference/config/networking/virtual-service/#HTTPRouteDestination</a> so I've defined <code>DestinationRule</code> and <code>VirtualService</code>:</p>

<pre><code>apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: downstream-destination
spec:
  host: downstream-service.svc.cluster.local
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: downstream-virtualservice
spec:
  hosts:
  - downstream-service.svc.cluster.local
  http:
  - name: "downstream-service-v1-routes"
    route:
    - destination:
        host: downstream-service.svc.cluster.local
        subset: v1
      weight: 5
  - name: "downstream-service-v2-routes"
    route:
    - destination:
        host: downstream-service.svc.cluster.local
        subset: v2
      weight: 95
</code></pre>

<p>but with this I'm still getting 50/50 split.</p>

<p>I've tried replacing <code>downstream-service.svc.cluster.local</code> with just <code>downstream-service</code> but the result was that without <code>weight</code>s defined in the yaml and with <code>subset</code>s removed I'd get a 50/50 split but when I've added the subset (without the weights) I'd get all the traffic on the <code>v1</code> instance.</p>

<p>What am I doing wrong here?</p>

<hr>

<p><strong>EDIT</strong></p>

<p>This might be the cause but I'm not sure what to make of it:</p>

<pre><code>$ istioctl x describe service downstream-service
Service: downstream-service
   Port:  80/auto-detect targets pod port 80
DestinationRule: downstream-service for "downstream-service"
   Matching subsets: v1,v2
   No Traffic Policy
VirtualService: downstream-route
   2 HTTP route(s)
$ istioctl x describe pod downstream-deployment-v2-69bdfc8fbf-bm22f
Pod: downstream-deployment-v2-69bdfc8fbf-bm22f
   Pod Ports: 80 (downstream), 15090 (istio-proxy)
--------------------
Service: downstream-service
   Port:  80/auto-detect targets pod port 80
DestinationRule: downstream-service for "downstream-service"
   Matching subsets: v2
      (Non-matching subsets v1)
   No Traffic Policy
VirtualService: downstream-route
   1 additional destination(s) that will not reach this pod
      Route to non-matching subset v1 for (everything)
$ istioctl x describe pod downstream-deployment-v1-65bd866c47-66p9k
Pod: downstream-deployment-v1-65bd866c47-66p9k
   Pod Ports: 80 (downstream), 15090 (istio-proxy)
--------------------
Service: downstream-service
   Port:  80/auto-detect targets pod port 80
DestinationRule: downstream-service for "downstream-service"
   Matching subsets: v1
      (Non-matching subsets v2)
   No Traffic Policy
VirtualService: downstream-route
   1 additional destination(s) that will not reach this pod
      Route to non-matching subset v2 for (everything)
</code></pre>

<p><strong>EDIT2</strong></p>

<p>So I've launched kiali just to see that:</p>

<p><a href="https://i.stack.imgur.com/UqCQE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UqCQE.png" alt="enter image description here"></a></p>

<blockquote>
  <p>The weight is assumed to be 100 because there is only one route destination</p>
</blockquote>

<p><a href="https://kiali.io/documentation/v1.13/validations/#_the_weight_is_assumed_to_be_100_because_there_is_only_one_route_destination" rel="nofollow noreferrer">https://kiali.io/documentation/v1.13/validations/#_the_weight_is_assumed_to_be_100_because_there_is_only_one_route_destination</a></p>

<p>Not sure how to fix this though.</p>

Patryk
<p>Ok, so it seems I've missed one big "typo" on my part which was the fact that it's the <code>routes</code> that have many <code>destination</code>s which are weighted not the <code>http</code> that has many weighted <code>route</code>s.</p>

<p>So the correct version of my <code>VirtualService</code> is as follows:</p>

<pre><code>apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: downstream-service
spec:
  hosts:
  - downstream-service
  http:
  - name: "downstream-service-routes"
    route:
    - destination:
        host: downstream-service
        subset: v1
      weight: 10
    - destination:
        host: downstream-service
        subset: v2
      weight: 90
</code></pre>
