Video in progress

When does adding a database check to the readiness probe do harm?

management:
  endpoint:
    health:
      group:
        readiness:
          include: readinessState, db, redis, paymentGateway

If all pods talk to one DB, during a short DB outage every pod becomes "not ready" at once, and the Service is left with no endpoints at all. The user gets a connection error instead of a clear one, and endpoints that could work without the cache or the DB go down too.

📖 Answer

With this configuration, if the payment provider stops responding for 30 seconds, all shop-api pods fail readiness. Browsing the catalog and the cart, which use the DB and Redis and have nothing to do with payment, stop working too. The impact of the problem spreads from one external system to the whole service.

The real question readiness asks is: "is it only this pod, unlike the others, that cannot accept traffic?" If the problem is shared by all pods, routing traffic to another pod solves nothing.

This is what I usually do:

management:
  endpoint:
    health:
      group:
        readiness:
          include: readinessState   # only the app's own state

For external dependencies:

  • a circuit breaker and timeouts, so the request returns quickly with a clear error (503 plus a readable message);
  • watch the dependency's state with a separate metric and alert, not in the probe;
  • there are exceptions: a resource specific to this pod, for example a local cache that has not warmed up yet, or this pod could not open its connection pool at all. Reporting that in readiness is right.

Putting an external dependency into liveness is even worse, because the pods restart nonstop.