I'm trying to use the lua-circuit-breaker plugin with ingress-nginx in a Kubernetes cluster. I want to set up two upstream servers such that the first is "wrapped" with this circuit breaker, and it falls back to a different upstream endpoint in case the circuit breaker is open. Both upstream servers are Kubernetes Service
s.
There are 2 things that I am unsure of at the moment.
- The plugin support of ingress-nginx seems to expect plugins to operate within certain callbacks like
init_worker
orrewrite
. I don't see how I can replicate the example in the lua-circuit-breaker plugin given that it sets up a local variable before the "wrapped" function and uses it after. As far as I know, I wouldn't be able to access thecb
variable in theheader_filter
callback if I initialize it in therewrite
callback. It doesn't seem to be possible to wrap the request within the scope of the variable. - I am not sure how to use Kubernetes
Ingress
objects to set up the fallback behavior. If I use aserver-snippet
I believe that only applies to a single upstream server and I can't set up multiple upstream servers in a single Ingress.
I sort-of hit a wall here with lack of familiarity of lua-nginx-module
that ingress-nginx
uses. Any help is greatly appreciated!