Score:1

How can I use a plugin in ingress-nginx to wrap a request?

es flag

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.

  1. The plugin support of ingress-nginx seems to expect plugins to operate within certain callbacks like init_worker or rewrite. 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 the cb variable in the header_filter callback if I initialize it in the rewrite callback. It doesn't seem to be possible to wrap the request within the scope of the variable.
  2. I am not sure how to use Kubernetes Ingress objects to set up the fallback behavior. If I use a server-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!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.