This project is in the process of being donated to the CNCF and is not affiliated with the Kubernetes project.

Buffering

Fine-tune connection speeds for read and write operations.

About read and write buffer limits

By default, K8sGateway is set up with 1MiB of request read and write buffer for each gateway listener. For large requests that must be buffered and that exceed the default buffer limit, K8sGateway either disconnects the connection to the downstream service if headers were already sent, or returns a 500 HTTP response code. To make sure that large requests can be sent and received, you can specify the maximum number of bytes that can be buffered between the gateway and the downstream service.

ℹ️
You can configure a maximum payload size on a gateway (perConnectionBufferLimitBytes) with the ListenerOption resource or on a route (perRequestBufferLimitBytes) with the RouteOption resource. The smaller size takes precedence. For example, if a gateway sets the maximum payload size to 10MB and the route to 15MB, the gateway maximum size is enforced. However, if the route size is only 5MB (less than the gateway), then the route maximum size is enforced. To configure different maximum payload sizes for specific workloads, set a larger size on the gateway. Then, set smaller sizes for each workload’s route. Routes that do not specify a maximum payload size inherit the payload size from the gateway.

Before you begin

  1. Follow the Get started guide to install K8sGateway, set up a gateway resource, and deploy the httpbin sample app.

  2. Get the external address of the gateway and save it in an environment variable.

    export INGRESS_GW_ADDRESS=$(kubectl get svc -n gloo-system gloo-proxy-http -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}")
    echo $INGRESS_GW_ADDRESS  
    kubectl port-forward deployment/gloo-proxy-http -n gloo-system 8080:8080

Set up connection buffer limits

  1. Create a ListenerOption resource to define your connection buffer limit rules.

    kubectl apply -f- <<EOF
    apiVersion: gateway.solo.io/v1
    kind: ListenerOption
    metadata:
      name: bufferlimits
      namespace: gloo-system
    spec:
      targetRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: http
      options:
        perConnectionBufferLimitBytes: 10485760
    EOF
  2. Verify that your configuration is applied by reviewing the Envoy configuration.

    1. Port forward the gloo-gateway-http deployment on port 19000.
      kubectl port-forward deploy/gloo-proxy-http -n gloo-system 19000 & 
    2. Open the config_dump endpoint.
      open http://localhost:19000/config_dump
    3. Look for the perConnectionBufferLimitBytes: 10485760 string in your Envoy configuration.

Cleanup

You can remove the resources that you created in this guide.
kubectl delete listeneroption bufferlimits -n gloo-system