Woodsman
Woodsman

Reputation: 1179

Where to put Istio network retry

I'm very new to Istio and not a Kubernetes expert, though I have used the latter.

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:

https://samirbehara.com/2019/06/05/retry-design-pattern-with-istio/

I have two questions:

  1. 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?

  2. 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.

Upvotes: 1

Views: 507

Answers (1)

paltaa
paltaa

Reputation: 3254

If the scalable service is returning 503, it makes sense to add a virtual service just like the blog example for serviceB and make serviceA connect to virtualServiceB which will do the retries to ServiceB

Now, for this to work (from within the cluster):

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: serviceB
spec:
  hosts:
  – serviceB
  http:
  – route:
    – destination:
        host: serviceB
    retries:
      attempts: 3
      perTryTimeout: 2s
      

These lines:

  hosts:
  – serviceB

Will tell the default Istio Gateway (mesh) to route all the traffic not to serviceB, but to virtualServiceB first which will then route to ServiceB. Then you will have retries from virtualServiceB to serviceB.

Hope this helps

Upvotes: 3

Related Questions