For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
HTTP/2 downstream
Tune HTTP/2 connection settings for downstream clients on a gateway listener.
Tune how the gateway handles HTTP/2 connections from downstream clients by configuring the http2ProtocolOptions field on a ListenerPolicy resource. You can control stream and connection flow-control window sizes and the maximum number of concurrent streams per connection.
Before you begin
-
Follow the Get started guide to install kgateway.
-
Follow the Sample app guide to create a gateway proxy with an HTTP listener and deploy the httpbin sample app.
-
Get the external address of the gateway and save it in an environment variable.
export INGRESS_GW_ADDRESS=$(kubectl get svc -n kgateway-system http -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}") echo $INGRESS_GW_ADDRESS
Configure downstream HTTP/2 settings
-
Create a ListenerPolicy that sets downstream HTTP/2 options on the gateway.
kubectl apply -f- <<EOF apiVersion: gateway.kgateway.dev/v1alpha1 kind: ListenerPolicy metadata: name: http2-settings namespace: kgateway-system spec: targetRefs: - group: gateway.networking.k8s.io kind: Gateway name: http default: httpSettings: http2ProtocolOptions: initialStreamWindowSize: 128Ki initialConnectionWindowSize: 256Ki maxConcurrentStreams: 100 EOFSetting Description initialStreamWindowSizeInitial flow-control window size for each HTTP/2 stream in bytes. Valid values: 65535–2147483647. Defaults to 268435456 (256 MiB). Accepts Kubernetes resource quantity strings, such as 128Ki.initialConnectionWindowSizeInitial flow-control window size for the HTTP/2 connection in bytes. Same valid range and default as initialStreamWindowSize. Accepts Kubernetes resource quantity strings such as256Ki.maxConcurrentStreamsMaximum number of concurrent HTTP/2 streams per connection in bytes. Valid values: 1–2147483647. Envoy defaults to 1024. -
Port-forward the gateway proxy on port 19000.
kubectl port-forward deployment/http -n kgateway-system 19000 -
Get the
http2_protocol_optionsvalues that are applied to the listener from the proxy’s config dump.curl -s 127.0.0.1:19000/config_dump | jq '.. | .http2_protocol_options? // empty | select(. != {})'Example output:
{ "initial_stream_window_size": 131072, "initial_connection_window_size": 262144, "max_concurrent_streams": 100 }
Other configurations
WebSocket over HTTP/2
By default, Envoy rejects Extended CONNECT requests (RFC 8441), which are used by some clients, such as Firefox, to establish WebSocket connections over HTTP/2. To allow these connections, set allowConnect: true in the http2ProtocolOptions field of a ListenerPolicy.
kubectl apply -f- <<EOF
apiVersion: gateway.kgateway.dev/v1alpha1
kind: ListenerPolicy
metadata:
name: http2-settings
namespace: kgateway-system
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: http
default:
httpSettings:
http2ProtocolOptions:
allowConnect: true
EOF| Setting | Description |
|---|---|
allowConnect | Enables RFC 8441 Extended CONNECT support on the HTTP/2 listener. Set to true to allow clients that use WebSocket-over-HTTP/2, such as Firefox, to establish WebSocket connections. Envoy translates the Extended CONNECT request into an HTTP/1.1 Upgrade before forwarding it to the upstream service. Defaults to false. |
Note
The allowConnect setting only allows the Extended CONNECT request through the gateway proxy. Envoy still converts it into a regular websocket upgrade internally, so you also need to enable the websocket upgrade token, either on the listener or on the route. For more information, see HTTP protocol upgrades.
Cleanup
You can remove the resources that you created in this guide.kubectl delete listenerpolicy http2-settings -n kgateway-system