Skip to content

feat(listenerpolicy): expose HTTP/2 allow_connect for WebSocket-over-HTTP/2#14323

Merged
davidjumani merged 2 commits into
kgateway-dev:mainfrom
Valyrian-Code:feat/http2-allow-connect
Jul 13, 2026
Merged

feat(listenerpolicy): expose HTTP/2 allow_connect for WebSocket-over-HTTP/2#14323
davidjumani merged 2 commits into
kgateway-dev:mainfrom
Valyrian-Code:feat/http2-allow-connect

Conversation

@Valyrian-Code

@Valyrian-Code Valyrian-Code commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Description

Envoy's HCM http2_protocol_options.allow_connect: true is required to handle WebSocket-over-HTTP/2 (RFC 8441 Extended CONNECT). Without it, when a listener advertises h2 in ALPN, user agents that use Extended CONNECT (e.g. Firefox) send an Extended CONNECT that Envoy does not translate to an HTTP/1.1 Upgrade against the upstream, so the upstream returns 426 missing Upgrade header. (Chrome happens to work because it falls back to a separate HTTP/1.1 connection for the WebSocket; Firefox does not.)

Previously the listener http2ProtocolOptions exposed only initialStreamWindowSize, initialConnectionWindowSize, and maxConcurrentStreams, so there was no way to enable allow_connect through any kgateway CRD.

This adds an allowConnect field to the listener http2ProtocolOptions (used by both ListenerPolicy and HTTPListenerPolicy) and maps it to Envoy's HttpConnectionManager.http2_protocol_options.allow_connect.

Example:

apiVersion: gateway.kgateway.dev/v1alpha1
kind: ListenerPolicy
metadata:
  name: ws-h2
spec:
  targetRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: example-gateway
  default:
    httpSettings:
      http2ProtocolOptions:
        allowConnect: true

Fixes #14305

Change Type

/kind new_feature

Changelog

Added `allowConnect` to listener `http2ProtocolOptions` (ListenerPolicy and HTTPListenerPolicy), mapping to Envoy's HCM `http2_protocol_options.allow_connect`, to support WebSocket-over-HTTP/2 (RFC 8441 Extended CONNECT).

Additional Notes

  • API field added to ListenerHTTP2ProtocolOptions (api/v1alpha1/kgateway/listener_policy_types.go); CRDs and deepcopy regenerated via make generate.
  • Translator wiring in pkg/kgateway/extensions2/plugins/listenerpolicy/http.go.
  • Golden translator tests extended for both ListenerPolicy and HTTPListenerPolicy.
  • Scope is intentionally limited to the downstream/listener HCM (the RFC 8441 case in the issue); upstream/backend Http2ProtocolOptions is unchanged.

…HTTP/2

Add an `allowConnect` field to the listener `http2ProtocolOptions` (ListenerPolicy
and HTTPListenerPolicy) that maps to Envoy's HttpConnectionManager
`http2_protocol_options.allow_connect`.

This is required to handle WebSocket-over-HTTP/2 (RFC 8441 Extended CONNECT) when
the listener advertises h2 in its ALPN. Without it, user agents that use Extended
CONNECT (e.g. Firefox) fail to establish WebSocket connections because Envoy does
not translate Extended CONNECT to an HTTP/1.1 Upgrade against the upstream.

Fixes kgateway-dev#14305

Signed-off-by: RAJVEER42 <[email protected]>
@Valyrian-Code
Valyrian-Code requested a review from a team as a code owner June 28, 2026 02:59
@gateway-bot gateway-bot added do-not-merge/kind-invalid Indicates a PR lacks a `kind/foo` label and requires one. release-note labels Jun 28, 2026
Copilot AI review requested due to automatic review settings July 13, 2026 15:40
@gateway-bot gateway-bot added kind/feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/kind-invalid Indicates a PR lacks a `kind/foo` label and requires one. labels Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for WebSocket-over-HTTP/2 (RFC 8441 Extended CONNECT) by exposing Envoy HCM http2_protocol_options.allow_connect through kgateway listener policy APIs, and wiring it into the listenerpolicy translation path.

Changes:

  • Added allowConnect to ListenerHTTP2ProtocolOptions (used by ListenerPolicy and HTTPListenerPolicy).
  • Wired allowConnect through translateHttp2ProtocolOptions to Envoy Http2ProtocolOptions.AllowConnect.
  • Regenerated CRD schemas/deepcopy and updated golden translator test inputs/outputs to cover the new field.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/kgateway/extensions2/plugins/listenerpolicy/http.go Maps ListenerHTTP2ProtocolOptions.AllowConnect into Envoy Http2ProtocolOptions.AllowConnect.
api/v1alpha1/kgateway/listener_policy_types.go Adds the new AllowConnect *bool API field with documentation.
api/v1alpha1/kgateway/zz_generated.deepcopy.go Regenerates deepcopy to include AllowConnect.
install/helm/kgateway-crds/templates/gateway.kgateway.dev_listenerpolicies.yaml Regenerates ListenerPolicy CRD schema to include allowConnect.
install/helm/kgateway-crds/templates/gateway.kgateway.dev_httplistenerpolicies.yaml Regenerates HTTPListenerPolicy CRD schema to include allowConnect.
pkg/kgateway/translator/gateway/testutils/inputs/listener-policy-http/http2-protocol-options.yaml Updates golden test input to set allowConnect: true.
pkg/kgateway/translator/gateway/testutils/inputs/httplistenerpolicy/http2-protocol-options.yaml Updates golden test input to set allowConnect: true.
pkg/kgateway/translator/gateway/testutils/outputs/listener-policy-http/http2-protocol-options.yaml Updates golden output to show http2ProtocolOptions.allowConnect: true in generated HCM config.
pkg/kgateway/translator/gateway/testutils/outputs/httplistenerpolicy/http2-protocol-options.yaml Updates golden output to show http2ProtocolOptions.allowConnect: true in generated HCM config.
Files not reviewed (1)
  • api/v1alpha1/kgateway/zz_generated.deepcopy.go: Generated file

@davidjumani
davidjumani enabled auto-merge July 13, 2026 16:25
@davidjumani
davidjumani added this pull request to the merge queue Jul 13, 2026
Merged via the queue into kgateway-dev:main with commit 1e259f0 Jul 13, 2026
57 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose envoy http2_protocol_options.allow_connect (WebSocket over HTTP/2 / RFC 8441)

4 participants