<p>I am watching a Pluralsight video on the Istio service mesh.  One part of the presentation says this:</p>
<blockquote>
<p>The VirtualService uses the Kubernetes service to find the IP addresses of all the pods.  The VirtualService doesn't route any traffic through the [Kubernetes] service, but it just uses it to get the list of endpoints where the traffic could go.</p>
</blockquote>
<p>And it shows this graphic (to show the pod discovery, not for traffic routing):</p>
<p><a href="https://i.stack.imgur.com/I38QT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/I38QT.png" alt="VirtualService uses Service to get IPs of pods" /></a></p>
<p>I am a bit confused by this because I don't know how an Istio <code>VirtualService</code> knows which Kubernetes <code>Service</code> to look at.  I don't see any reference in the example Istio <code>VirtualService</code> yaml files to a Kubernetes <code>Service</code>.</p>
<p>I have theorized that the <code>DestinationRules</code> could have enough labels on them to get down to just the needed pods, but the examples only use the labels <code>v1</code> and <code>v2</code>.  It seems unlikely that a version alone will give only the needed pods.  (Many different <code>Services</code> could be on <code>v1</code> or <code>v2</code>.)</p>
<p><strong>How does an Istio <code>VirtualService</code> know which Kubernetes <code>Service</code> to associate to?</strong></p>
<p>or said another way,</p>
<p><strong>How does an Istio <code>VirtualService</code> know how to find the correct pods from all the pods in the cluster?</strong></p>

Vaccano
<p>When creating a VitualService you define which service to find in <code>route.destination</code> section</p>
<p><code>port</code> : service running on port</p>
<p><code>host</code> : name of the service</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: test
spec:
  hosts:
  - &quot;example.com&quot;
  gateways:
  - test-gateway
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        port:
          number: 80
        host: app-service
</code></pre>
<p>so,</p>
<p><code>app-pod/s</code> -&gt; (managed by) <code>app-service</code> -&gt; <code>test</code> virtual service</p>
