<p>I can't use Kubernetes service as I need <code>retry</code> VirtualService feature. How can I access VirtualService from the pods?</p>
<p>If I use VirtualService through Gateway:
<code>Pod</code> -&gt; <code>Kubernetes service</code> -&gt; <code>Istio Gateway</code> -&gt; <code>Virtual service</code>
then for some reason <code>locality</code> balancing feature not working.</p>

Jonas
<p>I am guessing you have something like this:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: review-external
spec:
  hosts:
  - &quot;*.example.com&quot;
  gateways:
  - mygateway
  http:
    route:
    - destination:
        host: reviews.prod.svc.cluster.local
        subset: v2
      weight: 25
</code></pre>
<p>In that case you can use the <code>gateways</code> list in the <code>VirtualService</code> object for that.</p>
<p>For Docs:</p>
<blockquote>
<p>When this field is omitted, the default gateway (mesh) will be used, which would apply the rule to all sidecars in the mesh. If a list of gateway names is provided, the rules will apply only to the gateways. To apply the rules to both gateways and sidecars, specify mesh as one of the gateway names.</p>
</blockquote>
<p>Source:
<a href="https://istio.io/latest/zh/docs/reference/config/networking/virtual-service/#VirtualService" rel="nofollow noreferrer">https://istio.io/latest/zh/docs/reference/config/networking/virtual-service/#VirtualService</a></p>
<p>So you have two options here. You can either mention <code>mesh</code> as one of the gateways:</p>
<pre><code>[...]
  gateways:
  - mygateway
  - mesh
  http:
[...]
</code></pre>
<p>Or you could create a second <code>VirtualService</code> without the <code>gateways</code> list so it defaults to <code>mesh</code> (or mention only the mesh as gateway if you want to be declarative). The <code>spec.hosts</code> field must contain the host, that is mentioned in the <code>destination.host</code>.</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: review-mesh-internal
spec:
  hosts:
  - &quot;reviews.prod.svc.cluster.local&quot; # must be the kubernetes service host as below
  gateways:
  - mesh #optional since it's the default
  http:
    route:
    - destination:
        host: reviews.prod.svc.cluster.local
        subset: v1
      weight: 100
</code></pre>
<p>This brings the advantage, that you can route the traffic from outside the cluster differently than from inside the cluster. Think about maintenance for example, where user traffic should not reach a specific pod but traffic from inside the cluster should still be able to.</p>
