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 Services.
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_workerorrewrite. 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 thecbvariable in theheader_filtercallback if I initialize it in therewritecallback. 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
Ingressobjects to set up the fallback behavior. If I use aserver-snippetI 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!