Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase URL length limit for K8S ingress

I have a GET request URL into a service on my kubernetes that's ~9k long and it seems like the request is getting stuck in Kubernetes's ingress. When I tried calling the url from within the docker or from other docker in the cluster it works fine. However when I go through a domain name I'm getting the following response header:

enter image description here

like image 299
touchaponk Avatar asked Mar 04 '23 03:03

touchaponk


2 Answers

I think the parameter you must modify is Client Body Buffer Size

Sets buffer size for reading client request body per location. In case the request body is larger than the buffer, the whole body or only its part is written to a temporary file. By default, buffer size is equal to two memory pages. This is 8K on x86, other 32-bit platforms, and x86-64. It is usually 16K on other 64-bit platforms. This annotation is applied to each location provided in the ingress rule

nginx.ingress.kubernetes.io/client-body-buffer-size: "1000" # 1000 bytes
nginx.ingress.kubernetes.io/client-body-buffer-size: 1k # 1 kilobyte
nginx.ingress.kubernetes.io/client-body-buffer-size: 1K # 1 kilobyte
nginx.ingress.kubernetes.io/client-body-buffer-size: 1m # 1 megabyte

So you must add an annotation to your nginx ingress config.

like image 86
iliefa Avatar answered Mar 05 '23 18:03

iliefa


In my case, I had to set http2_max_header_size and http2_max_field_size in my ingress server-snippet annotation. For example:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/server-snippet: |
        http2_max_header_size 16k;
        http2_max_field_size 16k;

I was getting ERR_CONNECTION_CLOSED and ERR_FAILED in Google Chrome and "empty response" using curl, but the backend would work if accessed directly from the cluster network.

Assigning client-header-buffer-size or large-client-header-buffers in the ingress controller ConfigMap didn't seem to work for me either, but I realized that curl would do it if using HTTP 1.1 (curl --http1.1)

like image 43
Jesús Bocanegra Avatar answered Mar 05 '23 16:03

Jesús Bocanegra