<p>I'm very new to Istio and not a Kubernetes expert, though I have used the latter.</p>
<p>For simplicity, say I have two services, both Java/Spring Boot. Service A listens to requests from the outside world, Service B listens to requests from Service A. Service B is scalable, and at points might return 503. I wish to have service A retry calls to service B in a configurable non-programmatic way. Here's a blog/link that I tried to follow that I think is very similar:</p>
<p><a href="https://samirbehara.com/2019/06/05/retry-design-pattern-with-istio/" rel="nofollow noreferrer">https://samirbehara.com/2019/06/05/retry-design-pattern-with-istio/</a></p>
<p>I have two questions:</p>
<ol>
<li><p>It may seem obvious, but if I wanted to define a virtual retryable service, do I add it to the existing application.yml file for the project or is there some other file that the networking.istio.io/v1alpha3 goes?</p>
</li>
<li><p>Would I define the retry configuration in the yaml/repo for Service A or Service B? I can think of reasons for architecting Istio either way.</p>
</li>
</ol>

Woodsman
<p>If the scalable service is returning <code>503</code>, it makes sense to add a virtual service just like the blog example for <code>serviceB</code> and make <code>serviceA</code> connect to <code>virtualServiceB</code> which will do the retries to <code>ServiceB</code></p>
<p>Now, for this to work (from within the cluster):</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: serviceB
spec:
  hosts:
  – serviceB
  http:
  – route:
    – destination:
        host: serviceB
    retries:
      attempts: 3
      perTryTimeout: 2s
      
</code></pre>
<p>These lines:</p>
<pre><code>  hosts:
  – serviceB
</code></pre>
<p>Will tell the default Istio Gateway (mesh) to route all the traffic not to <code>serviceB</code>, but to  <code>virtualServiceB</code> first which will then route to <code>ServiceB</code>. Then you will have retries from <code>virtualServiceB</code> to <code>serviceB</code>.</p>
<p>Hope this helps</p>
