When deploying a Kong cluster to multiple data centers, is there a way to configure load balancing for an upstream such that requests stay in the same data center and only go to the other data center if/when targets are unhealthy in the local data center?
I saw that this question was asked a few years ago on github, the advice back then was to use DNS to handle this:
If I’m not able to modify DNS to return SRV records, are there any other options? One idea I had was to create separate upstreams for each data center and use a custom plugin that would dynamically re-assign the service’s upstream (via kong.service.set_upstream PDK function) based on health status of the “local” upstream. However, I’m not sure if I have easy access to the current health status for all targets on an upstream within a plugin. Is there a way to accomplish this out of the box? If not, thoughts on whether the plugin idea would work?