Skip to content

api: support customized UpgradeConfigs#5300

Merged
zirain merged 6 commits intoenvoyproxy:mainfrom
zirain:api/upgrde-configs
Feb 28, 2025
Merged

api: support customized UpgradeConfigs#5300
zirain merged 6 commits intoenvoyproxy:mainfrom
zirain:api/upgrde-configs

Conversation

@zirain
Copy link
Member

@zirain zirain commented Feb 18, 2025

xref: #4859 #3663 #5276

@zirain zirain requested a review from a team as a code owner February 18, 2025 03:49
@codecov
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.09%. Comparing base (c4bc5b2) to head (a82d567).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5300      +/-   ##
==========================================
- Coverage   65.10%   65.09%   -0.02%     
==========================================
  Files         213      213              
  Lines       33586    33586              
==========================================
- Hits        21867    21862       -5     
- Misses      10393    10397       +4     
- Partials     1326     1327       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arkodg
Copy link
Contributor

arkodg commented Feb 18, 2025

the other option is calling it backendProtocols, which relates to https://gateway-api.sigs.k8s.io/guides/backend-protocol/

@zirain zirain force-pushed the api/upgrde-configs branch from a21023f to dac924d Compare February 19, 2025 01:07
@arkodg
Copy link
Contributor

arkodg commented Feb 19, 2025

hey @zirain lets also make sure we address #3663 here
cc @denniskniep

@zirain zirain force-pushed the api/upgrde-configs branch from e42db4b to 9d7f274 Compare February 19, 2025 05:27
@denniskniep
Copy link
Contributor

Hi @zirain, thanks for tackling that topic!

You added the new config property to the BackendTrafficPolicy. The docs are defining it as:

BackendTrafficPolicy allows the user to configure the behavior of the connection between the Envoy Proxy listener and the backend service.

Isn´t http upgrade_type an HttpRoute specific thing? Just wondering if it makes sense to integrate it as implementation specific HTTPRouteFilter within ExtensionRef
There is already a complex filter defined in the spec: requestMirror

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: upgrade-example-com
spec:
  parentRefs:
  - name: eg
  hostnames:
  - "www.example.com"    
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /test
    filters:
    - type: ExtensionRef
      extensionRef:
        group: gateway.envoyproxy.io
        kind: HTTPRouteFilter
        name: upgrade-websockets
        
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: HTTPRouteFilter
metadata:
  name: upgrade-websockets
spec:
  upgrade:
    protocol: websocket
    disabled: false

Can we also tackle CONNECT_UDP ?

allows HTTP clients to create UDP tunnels through an HTTP proxy server. Unlike CONNECT, which is limited to tunneling TCP, CONNECT-UDP can be used to proxy UDP-based protocols such as HTTP/3.

Furthermore adding ConnectConfig as props would be nice. This can be specified if protocol is CONNECT or CONNECT-UDP

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: HTTPRouteFilter
metadata:
  name: upgrade-connect
spec:
  upgrade:
    disabled: false
    protocol: CONNECT
    connect:
      proxyProtocol:
        version: V2

@zirain
Copy link
Member Author

zirain commented Feb 20, 2025

IMO, upgrade is a thing per backend/port, not per route(even we will put the configuration on route, it's because we share the listener).

Is there a user case, we do the upgrade in one route and not in another route for the same backend?

@zirain zirain requested a review from arkodg February 21, 2025 01:41
@zirain zirain force-pushed the api/upgrde-configs branch from 1fd6425 to 495016c Compare February 22, 2025 05:19
@denniskniep
Copy link
Contributor

Is there a user case, we do the upgrade in one route and not in another route for the same backend?

tbh, not absolutely sure about that.

The property wouldn't have an effect if we use a tcp-route, right? So therefore I thought properties are added where the effect takes place.

Furthermore there is a related property per route that might be necessary to set in certain scenarios: connect_matcher

see here: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-routematch

@zirain
Copy link
Member Author

zirain commented Feb 22, 2025

The property wouldn't have an effect if we use a tcp-route, right?

Right, we named it as HTTPUpgrade.

@zirain
Copy link
Member Author

zirain commented Feb 22, 2025

Furthermore there is a related property per route that might be necessary to set in certain scenarios: connect_matcher

that's another feature, which is related more than protocol upgrade, in the future, we may need both to support connect matcher.

Copy link
Contributor

Choose a reason for hiding this comment

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

unsure here if we should be using Protocol or Type (for type of upgrade)

Copy link
Contributor

Choose a reason for hiding this comment

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

we could add a Connect field in this API in the future

connect:
  forwardTCP: false | true // Supports TCP tunnels
  allowHTTP2: false | true
  allowHTTP3: false | true

Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
@zirain zirain force-pushed the api/upgrde-configs branch from 495016c to 7a8424d Compare February 27, 2025 06:27
Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks !

@arkodg arkodg requested review from a team February 27, 2025 06:32
// e.g. `websocket`, `CONNECT`, `spdy/3.1` etc.
//
// +kubebuilder:validation:Required
Type string `json:"type"`
Copy link
Member

Choose a reason for hiding this comment

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

Should this be an enum?

Copy link
Member Author

Choose a reason for hiding this comment

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

the problem is that envoy didn't list all the protocol types it supported in doc.

Copy link
Member Author

Choose a reason for hiding this comment

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

prefer to leave it as string.

Copy link
Member

Choose a reason for hiding this comment

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

As a control plane we could be strict about what we support, but since proxy allows arbitrary string, so it's fine I guess.

@arkodg arkodg self-requested a review February 27, 2025 15:57
@arkodg
Copy link
Contributor

arkodg commented Feb 27, 2025

hey @zirain rethinking think one, as @denniskniep suggested HTTPRouteFilter may be a better fit here especially if we add upgrade.connect to this struct in the future
wdyt @envoyproxy/gateway-maintainers @envoyproxy/gateway-reviewers

@zirain
Copy link
Member Author

zirain commented Feb 27, 2025

Is there a user case, we do the upgrade in one route and not in another route for the same backend?

I replied this before, and we may need both in the future.

@zirain zirain merged commit 12c4390 into envoyproxy:main Feb 28, 2025
28 checks passed
@zirain zirain deleted the api/upgrde-configs branch February 28, 2025 05:06
@denniskniep
Copy link
Contributor

@zirain @arkodg

Is there a user case, we do the upgrade in one route and not in another route for the same backend?

I personally don´t have currently such a use case. But I guess that such use case can happen. If we just think that the upstream target is also kind of complex ReverseProxy, which offers different services behind one ip+port combination...

My point is why we are adding this feature/property to a resource where it is not as flexible as it would with the other choice/resource. I can´t see any further downsides shifting that property to HttpRoute

Furthermore the upgrade config is something which is going on between downstream and envoy. Maybe upgrade config has also influence to upstream, but that must not be the case. Looking especially at the http-connect config, this has nothing to do with the upstream, meaning BackendRef in our case.

Example:
downstream --Http upgrade:Connect--> envoy --plain tcp--> upstream

In this example the upgrade config is purely a setting between downstream and envoy. It would be counterintuitive to configure it on the upstream (backendRef)

At least my point of view. Am I missing something?

@zirain
Copy link
Member Author

zirain commented Feb 28, 2025

From my point of view, a gateway may have more than 1 httproute.

Thinking of I have N httproute in , before EG support #5351, you need to ref the route filter in every http route for that backend.

I'm not against copy this struct into HTTPRouteFilter so that we can customize for specified route.

ATM, you can ref BTP to Gateway or HTTPRoute, which sounds good to me.

I think this API solves #4859, but for #3663 we need more work on connect_match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants