feat: expose HTTP/2 connection keepalive in BackendConfigPolicy#14367
Merged
davidjumani merged 2 commits intoJul 13, 2026
Conversation
Adds connectionKeepalive (timeout, interval, connectionIdleInterval) to http2ProtocolOptions, mapping to Envoy's Http2ProtocolOptions.connection_keepalive (KeepaliveSettings). Enables active half-dead-connection detection for long-lived upstream HTTP/2 and gRPC connections: Envoy sends keepalive PINGs and closes the connection if no response arrives within the timeout, surfacing in the http2.keepalive_timeout stat. Previously requested in kgateway-dev#3740 (closed stale). tcpKeepalive covers the OS/TCP layer but cannot detect peers that are TCP-alive yet HTTP/2-dead (e.g. after NAT/LB state loss or a wedged remote process); HTTP/2 PING keepalive is the protocol-level complement. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Mark Johnson <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends kgateway’s BackendConfigPolicy HTTP/2 upstream configuration surface by adding spec.http2ProtocolOptions.connectionKeepalive, translating it into Envoy’s Http2ProtocolOptions.connection_keepalive to support HTTP/2 PING-based keepalive (half-dead connection detection) for long-lived upstream connections (e.g., gRPC).
Changes:
- Added
ConnectionKeepaliveAPI type underBackendConfigPolicy.spec.http2ProtocolOptionswith CEL validation (requiredtimeout, optionalintervalandconnectionIdleInterval). - Implemented translation to
envoycorev3.KeepaliveSettingsand applied it to HTTP/2 backends. - Updated generated artifacts (deepcopy + CRD) and added/updated translation + API validation tests.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/tests/apivalidation/apivalidation.go | Adds API validation coverage for invalid connectionKeepalive duration inputs. |
| pkg/kgateway/extensions2/plugins/backendconfigpolicy/protocoloptions.go | Translates connectionKeepalive into Envoy KeepaliveSettings in HTTP/2 protocol options. |
| pkg/kgateway/extensions2/plugins/backendconfigpolicy/plugin_test.go | Adds a unit test asserting the Envoy cluster config includes connection_keepalive for HTTP/2 backends. |
| install/helm/kgateway-crds/templates/gateway.kgateway.dev_backendconfigpolicies.yaml | Updates CRD schema to include connectionKeepalive and its validations. |
| api/v1alpha1/kgateway/zz_generated.deepcopy.go | Adds generated deepcopy support for the new ConnectionKeepalive type/field. |
| api/v1alpha1/kgateway/backend_config_policy_types.go | Introduces ConnectionKeepalive type and wires it into Http2ProtocolOptions. |
Files not reviewed (1)
- api/v1alpha1/kgateway/zz_generated.deepcopy.go: Generated file
… interval Matches the retry.perTryTimeout precedent: an unparseable duration fails both the format-regex rule and the duration() comparison rule, and the API server reports both. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Mark Johnson <[email protected]>
Contributor
Author
|
Filed #14381 as the accompanying feature issue for visibility/discussion. |
andy-fong
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #14381.
Adds
connectionKeepalivetoBackendConfigPolicy.spec.http2ProtocolOptions, mapping to Envoy'sHttp2ProtocolOptions.connection_keepalive:Motivation
Long-lived upstream HTTP/2 / gRPC connections can go half-dead — TCP-alive but HTTP/2-dead (NAT/LB state loss, wedged remote process).
tcpKeepalivecovers the OS layer but cannot detect this class; HTTP/2 PING keepalive is the protocol-level complement, and failures surface in thehttp2.keepalive_timeoutcluster stat for alerting. This was previously requested in #3740 (closed by stalebot in the gloo era).What's included
ConnectionKeepalivetype (requiredtimeout, optionalinterval/connectionIdleInterval), CEL duration validation consistent withtcpKeepaliveenvoycorev3.KeepaliveSettingsmake go-generate-apis)Merging of
http2ProtocolOptionsis unchanged — the block is already merged as a unit, so the new field participates automatically.Change Type
/kind new_feature
Changelog
🤖 Generated with Claude Code