Skip to content

Commit a1f8c9e

Browse files
authored
Allow changing per_connection_buffer_limit_bytes using contour configuration for clusters (#5493)
Fixes #5264 Fixes #1408 Signed-off-by: Rajat Vig <[email protected]>
1 parent 615d553 commit a1f8c9e

20 files changed

+275
-65
lines changed

apis/projectcontour/v1alpha1/contourconfig.go

+9
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,15 @@ type ClusterParameters struct {
605605
// +kubebuilder:validation:Minimum=1
606606
// +optional
607607
MaxRequestsPerConnection *uint32 `json:"maxRequestsPerConnection,omitempty"`
608+
609+
// Defines the soft limit on size of the cluster’s new connection read and write buffers in bytes.
610+
// If unspecified, an implementation defined default is applied (1MiB).
611+
// see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
612+
// for more information.
613+
//
614+
// +kubebuilder:validation:Minimum=1
615+
// +optional
616+
PerConnectionBufferLimitBytes *uint32 `json:"per-connection-buffer-limit-bytes,omitempty"`
608617
}
609618

610619
// HTTPProxyConfig defines parameters on HTTPProxy.

apis/projectcontour/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Allow setting of `per_connection_buffer_limit_bytes` value for Clusters
2+
3+
Allow changing `per_connection_buffer_limit_bytes` for all Clusters. Default is not set to keep compatibility with existing configurations. Envoy [recommends](https://www.envoyproxy.io/docs/envoy/latest/configuration/best_practices/edge) setting to 32KiB for Edge proxies.

cmd/contour/serve.go

+26-19
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ func (s *Server) doServe() error {
517517
httpsPort: contourConfiguration.Envoy.HTTPSListener.Port,
518518
globalExternalAuthorizationService: contourConfiguration.GlobalExternalAuthorization,
519519
maxRequestsPerConnection: contourConfiguration.Envoy.Cluster.MaxRequestsPerConnection,
520+
perConnectionBufferLimitBytes: contourConfiguration.Envoy.Cluster.PerConnectionBufferLimitBytes,
520521
})
521522

522523
// Build the core Kubernetes event handler.
@@ -1048,6 +1049,7 @@ type dagBuilderConfig struct {
10481049
httpsPort int
10491050
globalExternalAuthorizationService *contour_api_v1.AuthorizationServer
10501051
maxRequestsPerConnection *uint32
1052+
perConnectionBufferLimitBytes *uint32
10511053
}
10521054

10531055
func (s *Server) getDAGBuilder(dbc dagBuilderConfig) *dag.Builder {
@@ -1109,12 +1111,14 @@ func (s *Server) getDAGBuilder(dbc dagBuilderConfig) *dag.Builder {
11091111
HTTPSPort: dbc.httpsPort,
11101112
},
11111113
&dag.IngressProcessor{
1112-
EnableExternalNameService: dbc.enableExternalNameService,
1113-
FieldLogger: s.log.WithField("context", "IngressProcessor"),
1114-
ClientCertificate: dbc.clientCert,
1115-
RequestHeadersPolicy: &requestHeadersPolicyIngress,
1116-
ResponseHeadersPolicy: &responseHeadersPolicyIngress,
1117-
ConnectTimeout: dbc.connectTimeout,
1114+
EnableExternalNameService: dbc.enableExternalNameService,
1115+
FieldLogger: s.log.WithField("context", "IngressProcessor"),
1116+
ClientCertificate: dbc.clientCert,
1117+
RequestHeadersPolicy: &requestHeadersPolicyIngress,
1118+
ResponseHeadersPolicy: &responseHeadersPolicyIngress,
1119+
ConnectTimeout: dbc.connectTimeout,
1120+
MaxRequestsPerConnection: dbc.maxRequestsPerConnection,
1121+
PerConnectionBufferLimitBytes: dbc.perConnectionBufferLimitBytes,
11181122
},
11191123
&dag.ExtensionServiceProcessor{
11201124
// Note that ExtensionService does not support ExternalName, if it does get added,
@@ -1124,24 +1128,27 @@ func (s *Server) getDAGBuilder(dbc dagBuilderConfig) *dag.Builder {
11241128
ConnectTimeout: dbc.connectTimeout,
11251129
},
11261130
&dag.HTTPProxyProcessor{
1127-
EnableExternalNameService: dbc.enableExternalNameService,
1128-
DisablePermitInsecure: dbc.disablePermitInsecure,
1129-
FallbackCertificate: dbc.fallbackCert,
1130-
DNSLookupFamily: dbc.dnsLookupFamily,
1131-
ClientCertificate: dbc.clientCert,
1132-
RequestHeadersPolicy: &requestHeadersPolicy,
1133-
ResponseHeadersPolicy: &responseHeadersPolicy,
1134-
ConnectTimeout: dbc.connectTimeout,
1135-
GlobalExternalAuthorization: dbc.globalExternalAuthorizationService,
1136-
MaxRequestsPerConnection: dbc.maxRequestsPerConnection,
1131+
EnableExternalNameService: dbc.enableExternalNameService,
1132+
DisablePermitInsecure: dbc.disablePermitInsecure,
1133+
FallbackCertificate: dbc.fallbackCert,
1134+
DNSLookupFamily: dbc.dnsLookupFamily,
1135+
ClientCertificate: dbc.clientCert,
1136+
RequestHeadersPolicy: &requestHeadersPolicy,
1137+
ResponseHeadersPolicy: &responseHeadersPolicy,
1138+
ConnectTimeout: dbc.connectTimeout,
1139+
GlobalExternalAuthorization: dbc.globalExternalAuthorizationService,
1140+
MaxRequestsPerConnection: dbc.maxRequestsPerConnection,
1141+
PerConnectionBufferLimitBytes: dbc.perConnectionBufferLimitBytes,
11371142
},
11381143
}
11391144

11401145
if len(dbc.gatewayControllerName) > 0 || dbc.gatewayRef != nil {
11411146
dagProcessors = append(dagProcessors, &dag.GatewayAPIProcessor{
1142-
EnableExternalNameService: dbc.enableExternalNameService,
1143-
FieldLogger: s.log.WithField("context", "GatewayAPIProcessor"),
1144-
ConnectTimeout: dbc.connectTimeout,
1147+
EnableExternalNameService: dbc.enableExternalNameService,
1148+
FieldLogger: s.log.WithField("context", "GatewayAPIProcessor"),
1149+
ConnectTimeout: dbc.connectTimeout,
1150+
MaxRequestsPerConnection: dbc.maxRequestsPerConnection,
1151+
PerConnectionBufferLimitBytes: dbc.perConnectionBufferLimitBytes,
11451152
})
11461153
}
11471154

cmd/contour/servecontext.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,9 @@ func (ctx *serveContext) convertToContourConfigurationSpec() contour_api_v1alpha
560560
DefaultHTTPVersions: defaultHTTPVersions,
561561
Timeouts: timeoutParams,
562562
Cluster: &contour_api_v1alpha1.ClusterParameters{
563-
DNSLookupFamily: dnsLookupFamily,
564-
MaxRequestsPerConnection: ctx.Config.Cluster.MaxRequestsPerConnection,
563+
DNSLookupFamily: dnsLookupFamily,
564+
MaxRequestsPerConnection: ctx.Config.Cluster.MaxRequestsPerConnection,
565+
PerConnectionBufferLimitBytes: ctx.Config.Cluster.PerConnectionBufferLimitBytes,
565566
},
566567
Network: &contour_api_v1alpha1.NetworkParameters{
567568
XffNumTrustedHops: &ctx.Config.Network.XffNumTrustedHops,

examples/contour/01-crds.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ spec:
102102
format: int32
103103
minimum: 1
104104
type: integer
105+
per-connection-buffer-limit-bytes:
106+
description: Defines the soft limit on size of the cluster’s
107+
new connection read and write buffers in bytes. If unspecified,
108+
an implementation defined default is applied (1MiB). see
109+
https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
110+
for more information.
111+
format: int32
112+
minimum: 1
113+
type: integer
105114
type: object
106115
defaultHTTPVersions:
107116
description: "DefaultHTTPVersions defines the default set of HTTPS
@@ -3297,6 +3306,15 @@ spec:
32973306
format: int32
32983307
minimum: 1
32993308
type: integer
3309+
per-connection-buffer-limit-bytes:
3310+
description: Defines the soft limit on size of the cluster’s
3311+
new connection read and write buffers in bytes. If unspecified,
3312+
an implementation defined default is applied (1MiB).
3313+
see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
3314+
for more information.
3315+
format: int32
3316+
minimum: 1
3317+
type: integer
33003318
type: object
33013319
defaultHTTPVersions:
33023320
description: "DefaultHTTPVersions defines the default set

examples/render/contour-deployment.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,15 @@ spec:
315315
format: int32
316316
minimum: 1
317317
type: integer
318+
per-connection-buffer-limit-bytes:
319+
description: Defines the soft limit on size of the cluster’s
320+
new connection read and write buffers in bytes. If unspecified,
321+
an implementation defined default is applied (1MiB). see
322+
https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
323+
for more information.
324+
format: int32
325+
minimum: 1
326+
type: integer
318327
type: object
319328
defaultHTTPVersions:
320329
description: "DefaultHTTPVersions defines the default set of HTTPS
@@ -3510,6 +3519,15 @@ spec:
35103519
format: int32
35113520
minimum: 1
35123521
type: integer
3522+
per-connection-buffer-limit-bytes:
3523+
description: Defines the soft limit on size of the cluster’s
3524+
new connection read and write buffers in bytes. If unspecified,
3525+
an implementation defined default is applied (1MiB).
3526+
see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
3527+
for more information.
3528+
format: int32
3529+
minimum: 1
3530+
type: integer
35133531
type: object
35143532
defaultHTTPVersions:
35153533
description: "DefaultHTTPVersions defines the default set

examples/render/contour-gateway-provisioner.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ spec:
116116
format: int32
117117
minimum: 1
118118
type: integer
119+
per-connection-buffer-limit-bytes:
120+
description: Defines the soft limit on size of the cluster’s
121+
new connection read and write buffers in bytes. If unspecified,
122+
an implementation defined default is applied (1MiB). see
123+
https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
124+
for more information.
125+
format: int32
126+
minimum: 1
127+
type: integer
119128
type: object
120129
defaultHTTPVersions:
121130
description: "DefaultHTTPVersions defines the default set of HTTPS
@@ -3311,6 +3320,15 @@ spec:
33113320
format: int32
33123321
minimum: 1
33133322
type: integer
3323+
per-connection-buffer-limit-bytes:
3324+
description: Defines the soft limit on size of the cluster’s
3325+
new connection read and write buffers in bytes. If unspecified,
3326+
an implementation defined default is applied (1MiB).
3327+
see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
3328+
for more information.
3329+
format: int32
3330+
minimum: 1
3331+
type: integer
33143332
type: object
33153333
defaultHTTPVersions:
33163334
description: "DefaultHTTPVersions defines the default set

examples/render/contour-gateway.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,15 @@ spec:
321321
format: int32
322322
minimum: 1
323323
type: integer
324+
per-connection-buffer-limit-bytes:
325+
description: Defines the soft limit on size of the cluster’s
326+
new connection read and write buffers in bytes. If unspecified,
327+
an implementation defined default is applied (1MiB). see
328+
https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
329+
for more information.
330+
format: int32
331+
minimum: 1
332+
type: integer
324333
type: object
325334
defaultHTTPVersions:
326335
description: "DefaultHTTPVersions defines the default set of HTTPS
@@ -3516,6 +3525,15 @@ spec:
35163525
format: int32
35173526
minimum: 1
35183527
type: integer
3528+
per-connection-buffer-limit-bytes:
3529+
description: Defines the soft limit on size of the cluster’s
3530+
new connection read and write buffers in bytes. If unspecified,
3531+
an implementation defined default is applied (1MiB).
3532+
see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
3533+
for more information.
3534+
format: int32
3535+
minimum: 1
3536+
type: integer
35193537
type: object
35203538
defaultHTTPVersions:
35213539
description: "DefaultHTTPVersions defines the default set

examples/render/contour.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,15 @@ spec:
315315
format: int32
316316
minimum: 1
317317
type: integer
318+
per-connection-buffer-limit-bytes:
319+
description: Defines the soft limit on size of the cluster’s
320+
new connection read and write buffers in bytes. If unspecified,
321+
an implementation defined default is applied (1MiB). see
322+
https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
323+
for more information.
324+
format: int32
325+
minimum: 1
326+
type: integer
318327
type: object
319328
defaultHTTPVersions:
320329
description: "DefaultHTTPVersions defines the default set of HTTPS
@@ -3510,6 +3519,15 @@ spec:
35103519
format: int32
35113520
minimum: 1
35123521
type: integer
3522+
per-connection-buffer-limit-bytes:
3523+
description: Defines the soft limit on size of the cluster’s
3524+
new connection read and write buffers in bytes. If unspecified,
3525+
an implementation defined default is applied (1MiB).
3526+
see https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
3527+
for more information.
3528+
format: int32
3529+
minimum: 1
3530+
type: integer
35133531
type: object
35143532
defaultHTTPVersions:
35153533
description: "DefaultHTTPVersions defines the default set

internal/dag/dag.go

+3
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,9 @@ type Cluster struct {
997997

998998
// MaxRequestsPerConnection defines the maximum number of requests per connection to the upstream before it is closed.
999999
MaxRequestsPerConnection *uint32
1000+
1001+
// PerConnectionBufferLimitBytes defines the soft limit on size of the cluster’s new connection read and write buffers.
1002+
PerConnectionBufferLimitBytes *uint32
10001003
}
10011004

10021005
// WeightedService represents the load balancing weight of a

0 commit comments

Comments
 (0)