Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase max request body size on nginx ingress controller and kong

I have an a service that accepts POSTs with base64 encoded files in the body. I'm currently getting Error: 413 Request Entity Too Large when I POST anything larger than 1MB, otherwise it works fine.

My setup has kong proxying to the service. I have the following annotation for the proxy's ingress installed via the stable kong helm chart :

      kubernetes.io/ingress.class: "nginx"
      ingress.kubernetes.io/ssl-redirect: “true”
      ingress.kubernetes.io/proxy-body-size: 50m

I also added this to the kong env values:

client_max_body_size: 0

My understanding is this should update the nginx.conf

Kong has an nginx-ingress sitting in front of it which I installed with the stable helm chart. For the ingress-controller I have set:

--set controller.config.proxy-body-size: "50m"

However none of these settings are working. Looking through the ingress-controller's pod logs I see:

2019/08/02 15:01:34 [warn] 42#42: *810139 a client request body is buffered to a temporary file /tmp/client-body/0000000014, client: 1X.XXX.X0.X, server: example.com, request: "POST /endpoint HTTP/1.1", host: "example.com"

And the corresponding log in the kong pod:

2019/08/02 15:01:39 [warn] 33#0: *1147388 a client request body is buffered to a temporary file /usr/local/kong/client_body_temp/0000000017, client: XX.XXX.XXX.XX, server: kong, request: "POST /ENDPOINT HTTP/1.1", host: "example.com"
10.120.20.17 - - [02/Aug/2019:15:01:39 +0000] "POST /endpoint HTTP/1.1" 413 794 "-" "PostmanRuntime/7.15.2"

Is there another setting I am missing or am I going about this wrong? How can I get this to work as expected.

  • If I just POST to the pod directly using it's IP, no ingress controllers involved I get the same 413 error. Does kubernetes have a default ingress somewhere that also needs to be changed?
like image 632
dweeb Avatar asked Aug 02 '19 15:08

dweeb


People also ask

What is nginx ingress kubernetes IO proxy body size?

nginx.ingress.kubernetes.io/proxy-body-size: 8m. Note: The default value of the proxy-body-size is 1 M. Make sure to change the number to the size you need. Note: In some cases, you might need to increase the maximum size for all post body data and file uploads.

What is nginx ingress kubernetes IO limit RPS?

nginx.ingress.kubernetes.io/limit-connections : this defines the number of concurrent connections allowed from an IP address. nginx.ingress.kubernetes.io/limit-rps : rps stands for “request per second”, and it is used to define the number of connections that may be accepted from an IP per second.

Which protocol does nginx ingress controller handle?

NGINX Ingress resources support additional protocols (TCP, UDP, and TLS Passthrough) – You can now deliver complex, non-HTTP-based services from Kubernetes using custom resources, in a simple and intuitive manner.

What is nginx ingress kubernetes IO configuration snippet?

The configuration-snippet is to add configs to locations. If you want to add a custom location to the server context, you should use the server-snippet instead: Using the annotation nginx.ingress.kubernetes.io/server-snippet it is possible to add custom configuration in the server configuration block.


1 Answers

the annotation seemed to work fine. The limitation I was running into was because the code I was testing was in a kubeless. The kubeless functions use bottle and the ingress limit was on bottle. I increased that in a custom python3.7 image for kubeless and all worked fine.

like image 77
dweeb Avatar answered Oct 14 '22 05:10

dweeb