Skip to content

Commit 73ea351

Browse files
committed
Make haproxy maxconn configurable
The haproxy maxconn (maximum connections) is by default 2000. This change makes that configurable through the oadm router --max-connections= option when creating a router. For existing routers the value can be set in the ROUTER_MAX_CONNECTIONS environment variable. openshift-docs PR 3609 bug 1405440 https://bugzilla.redhat.com/show_bug.cgi?id=1405440
1 parent d776328 commit 73ea351

File tree

16 files changed

+61
-2
lines changed

16 files changed

+61
-2
lines changed

contrib/completions/bash/oadm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4612,6 +4612,8 @@ _oadm_router()
46124612
local_nonpersistent_flags+=("--labels=")
46134613
flags+=("--latest-images")
46144614
local_nonpersistent_flags+=("--latest-images")
4615+
flags+=("--max-connections=")
4616+
local_nonpersistent_flags+=("--max-connections=")
46154617
flags+=("--metrics-image=")
46164618
local_nonpersistent_flags+=("--metrics-image=")
46174619
flags+=("--output=")

contrib/completions/bash/oc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4619,6 +4619,8 @@ _oc_adm_router()
46194619
local_nonpersistent_flags+=("--labels=")
46204620
flags+=("--latest-images")
46214621
local_nonpersistent_flags+=("--latest-images")
4622+
flags+=("--max-connections=")
4623+
local_nonpersistent_flags+=("--max-connections=")
46224624
flags+=("--metrics-image=")
46234625
local_nonpersistent_flags+=("--metrics-image=")
46244626
flags+=("--output=")

contrib/completions/bash/openshift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4612,6 +4612,8 @@ _openshift_admin_router()
46124612
local_nonpersistent_flags+=("--labels=")
46134613
flags+=("--latest-images")
46144614
local_nonpersistent_flags+=("--latest-images")
4615+
flags+=("--max-connections=")
4616+
local_nonpersistent_flags+=("--max-connections=")
46154617
flags+=("--metrics-image=")
46164618
local_nonpersistent_flags+=("--metrics-image=")
46174619
flags+=("--output=")
@@ -9520,6 +9522,8 @@ _openshift_cli_adm_router()
95209522
local_nonpersistent_flags+=("--labels=")
95219523
flags+=("--latest-images")
95229524
local_nonpersistent_flags+=("--latest-images")
9525+
flags+=("--max-connections=")
9526+
local_nonpersistent_flags+=("--max-connections=")
95239527
flags+=("--metrics-image=")
95249528
local_nonpersistent_flags+=("--metrics-image=")
95259529
flags+=("--output=")
@@ -21980,6 +21984,8 @@ _openshift_infra_router()
2198021984
local_nonpersistent_flags+=("--labels=")
2198121985
flags+=("--master=")
2198221986
local_nonpersistent_flags+=("--master=")
21987+
flags+=("--max-connections=")
21988+
local_nonpersistent_flags+=("--max-connections=")
2198321989
flags+=("--name=")
2198421990
local_nonpersistent_flags+=("--name=")
2198521991
flags+=("--namespace=")

contrib/completions/zsh/oadm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4760,6 +4760,8 @@ _oadm_router()
47604760
local_nonpersistent_flags+=("--labels=")
47614761
flags+=("--latest-images")
47624762
local_nonpersistent_flags+=("--latest-images")
4763+
flags+=("--max-connections=")
4764+
local_nonpersistent_flags+=("--max-connections=")
47634765
flags+=("--metrics-image=")
47644766
local_nonpersistent_flags+=("--metrics-image=")
47654767
flags+=("--output=")

contrib/completions/zsh/oc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4767,6 +4767,8 @@ _oc_adm_router()
47674767
local_nonpersistent_flags+=("--labels=")
47684768
flags+=("--latest-images")
47694769
local_nonpersistent_flags+=("--latest-images")
4770+
flags+=("--max-connections=")
4771+
local_nonpersistent_flags+=("--max-connections=")
47704772
flags+=("--metrics-image=")
47714773
local_nonpersistent_flags+=("--metrics-image=")
47724774
flags+=("--output=")

contrib/completions/zsh/openshift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4760,6 +4760,8 @@ _openshift_admin_router()
47604760
local_nonpersistent_flags+=("--labels=")
47614761
flags+=("--latest-images")
47624762
local_nonpersistent_flags+=("--latest-images")
4763+
flags+=("--max-connections=")
4764+
local_nonpersistent_flags+=("--max-connections=")
47634765
flags+=("--metrics-image=")
47644766
local_nonpersistent_flags+=("--metrics-image=")
47654767
flags+=("--output=")
@@ -9668,6 +9670,8 @@ _openshift_cli_adm_router()
96689670
local_nonpersistent_flags+=("--labels=")
96699671
flags+=("--latest-images")
96709672
local_nonpersistent_flags+=("--latest-images")
9673+
flags+=("--max-connections=")
9674+
local_nonpersistent_flags+=("--max-connections=")
96719675
flags+=("--metrics-image=")
96729676
local_nonpersistent_flags+=("--metrics-image=")
96739677
flags+=("--output=")
@@ -22128,6 +22132,8 @@ _openshift_infra_router()
2212822132
local_nonpersistent_flags+=("--labels=")
2212922133
flags+=("--master=")
2213022134
local_nonpersistent_flags+=("--master=")
22135+
flags+=("--max-connections=")
22136+
local_nonpersistent_flags+=("--max-connections=")
2213122137
flags+=("--name=")
2213222138
local_nonpersistent_flags+=("--name=")
2213322139
flags+=("--namespace=")

docs/man/man1/oadm-router.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ If a router does not exist with the given name, this command will create a deplo
107107
\fB\-\-latest\-images\fP=false
108108
If true, attempt to use the latest images for the router instead of the latest release.
109109

110+
.PP
111+
\fB\-\-max\-connections\fP=2000
112+
MaxConnections specifies the maximum number of concurrent connections. Default 2000
113+
110114
.PP
111115
\fB\-\-metrics\-image\fP=""
112116
If \-\-expose\-metrics is specified this is the image to use to run a sidecar container in the pod exposing metrics. If not set and \-\-expose\-metrics is true the image will depend on router implementation.

docs/man/man1/oc-adm-router.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ If a router does not exist with the given name, this command will create a deplo
107107
\fB\-\-latest\-images\fP=false
108108
If true, attempt to use the latest images for the router instead of the latest release.
109109

110+
.PP
111+
\fB\-\-max\-connections\fP=2000
112+
MaxConnections specifies the maximum number of concurrent connections. Default 2000
113+
110114
.PP
111115
\fB\-\-metrics\-image\fP=""
112116
If \-\-expose\-metrics is specified this is the image to use to run a sidecar container in the pod exposing metrics. If not set and \-\-expose\-metrics is true the image will depend on router implementation.

docs/man/man1/openshift-admin-router.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ If a router does not exist with the given name, this command will create a deplo
107107
\fB\-\-latest\-images\fP=false
108108
If true, attempt to use the latest images for the router instead of the latest release.
109109

110+
.PP
111+
\fB\-\-max\-connections\fP=2000
112+
MaxConnections specifies the maximum number of concurrent connections. Default 2000
113+
110114
.PP
111115
\fB\-\-metrics\-image\fP=""
112116
If \-\-expose\-metrics is specified this is the image to use to run a sidecar container in the pod exposing metrics. If not set and \-\-expose\-metrics is true the image will depend on router implementation.

docs/man/man1/openshift-cli-adm-router.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ If a router does not exist with the given name, this command will create a deplo
107107
\fB\-\-latest\-images\fP=false
108108
If true, attempt to use the latest images for the router instead of the latest release.
109109

110+
.PP
111+
\fB\-\-max\-connections\fP=2000
112+
MaxConnections specifies the maximum number of concurrent connections. Default 2000
113+
110114
.PP
111115
\fB\-\-metrics\-image\fP=""
112116
If \-\-expose\-metrics is specified this is the image to use to run a sidecar container in the pod exposing metrics. If not set and \-\-expose\-metrics is true the image will depend on router implementation.

docs/man/man1/openshift-infra-router.1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ You may restrict the set of routes exposed to a single project (with \-\-namespa
135135
\[la]http://localhost:8080"\[ra]
136136
The address the master can be reached on (host, host:port, or URL).
137137

138+
.PP
139+
\fB\-\-max\-connections\fP="2000"
140+
MaxConnections specifies the maximum number of concurrent connections. Default 2000
141+
138142
.PP
139143
\fB\-\-name\fP="public"
140144
The name the router will identify itself with in the route status

images/router/haproxy/conf/haproxy-config.template

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
{{ define "/var/lib/haproxy/conf/haproxy.config" }}
77
{{ $workingDir := .WorkingDir }}
88
global
9-
# maxconn 4096
9+
maxconn {{env "ROUTER_MAX_CONNECTIONS" "20000"}}
10+
1011
daemon
1112
{{ with (env "ROUTER_SYSLOG_ADDRESS" "") }}
1213
log {{.}} local1 {{env "ROUTER_LOG_LEVEL" "warning"}}
@@ -33,7 +34,8 @@ global
3334
# ssl-default-bind-ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
3435

3536
defaults
36-
# maxconn 4096
37+
maxconn {{env "ROUTER_MAX_CONNECTIONS" "20000"}}
38+
3739
# Add x-forwarded-for header.
3840
{{ if ne (env "ROUTER_SYSLOG_ADDRESS" "") ""}}
3941
option httplog

pkg/cmd/admin/router/router.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ type RouterConfig struct {
215215
// restricted, or if all the users can be trusted.
216216
DisableNamespaceOwnershipCheck bool
217217

218+
// MaxConnections specifies the maximum number of concurrent
219+
// connections. Default defaultMaxConnections
220+
MaxConnections int
221+
218222
// ExposeMetrics is a hint on whether to expose metrics.
219223
ExposeMetrics bool
220224

@@ -232,6 +236,9 @@ const (
232236
// Default stats and healthz port.
233237
defaultStatsPort = 1936
234238
defaultHealthzPort = defaultStatsPort
239+
240+
// Default maximum number of connections
241+
defaultMaxConnections = 2000
235242
)
236243

237244
// NewCmdRouter implements the OpenShift CLI router command.
@@ -250,6 +257,8 @@ func NewCmdRouter(f *clientcmd.Factory, parentName, name string, out, errout io.
250257
StatsPort: defaultStatsPort,
251258
HostNetwork: true,
252259
HostPorts: true,
260+
261+
MaxConnections: defaultMaxConnections,
253262
}
254263

255264
cmd := &cobra.Command{
@@ -299,6 +308,7 @@ func NewCmdRouter(f *clientcmd.Factory, parentName, name string, out, errout io.
299308
cmd.Flags().BoolVar(&cfg.ExternalHostInsecure, "external-host-insecure", cfg.ExternalHostInsecure, "If the underlying router implementation connects with an external host over a secure connection, this causes the router to skip strict certificate verification with the external host.")
300309
cmd.Flags().StringVar(&cfg.ExternalHostPartitionPath, "external-host-partition-path", cfg.ExternalHostPartitionPath, "If the underlying router implementation uses partitions for control boundaries, this is the path to use for that partition.")
301310
cmd.Flags().BoolVar(&cfg.DisableNamespaceOwnershipCheck, "disable-namespace-ownership-check", cfg.DisableNamespaceOwnershipCheck, "Disables the namespace ownership check and allows different namespaces to claim either different paths to a route host or overlapping host names in case of a wildcard route. The default behavior (false) to restrict claims to the oldest namespace that has claimed either the host or the subdomain. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.")
311+
cmd.Flags().IntVar(&cfg.MaxConnections, "max-connections", cfg.MaxConnections, "MaxConnections specifies the maximum number of concurrent connections. Default 2000")
302312

303313
cfg.Action.BindForOutput(cmd.Flags())
304314
cmd.Flags().String("output-version", "", "The preferred API versions of the output objects")
@@ -641,6 +651,7 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
641651
"STATS_PORT": strconv.Itoa(cfg.StatsPort),
642652
"STATS_USERNAME": cfg.StatsUsername,
643653
"STATS_PASSWORD": cfg.StatsPassword,
654+
"ROUTER_MAX_CONNECTIONS": strconv.Itoa(cfg.MaxConnections),
644655
}
645656
if len(cfg.ForceSubdomain) > 0 {
646657
env["ROUTER_SUBDOMAIN"] = cfg.ForceSubdomain

pkg/cmd/infra/router/template.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ type TemplateRouter struct {
6565
ExtendedValidation bool
6666
RouterService *ktypes.NamespacedName
6767
BindPortsAfterSync bool
68+
MaxConnections string
6869
}
6970

7071
// reloadInterval returns how often to run the router reloads. The interval
@@ -91,6 +92,7 @@ func (o *TemplateRouter) Bind(flag *pflag.FlagSet) {
9192
flag.DurationVar(&o.ReloadInterval, "interval", reloadInterval(), "Controls how often router reloads are invoked. Mutiple router reload requests are coalesced for the duration of this interval since the last reload time.")
9293
flag.BoolVar(&o.ExtendedValidation, "extended-validation", util.Env("EXTENDED_VALIDATION", "true") == "true", "If set, then an additional extended validation step is performed on all routes admitted in by this router. Defaults to true and enables the extended validation checks.")
9394
flag.BoolVar(&o.BindPortsAfterSync, "bind-ports-after-sync", util.Env("ROUTER_BIND_PORTS_AFTER_SYNC", "") == "true", "Bind ports only after route state has been synchronized")
95+
flag.StringVar(&o.MaxConnections, "max-connections", util.Env("ROUTER_MAX_CONNECTIONS", "2000"), "MaxConnections specifies the maximum number of concurrent connections. Default 2000")
9496
}
9597

9698
type RouterStats struct {
@@ -206,6 +208,7 @@ func (o *TemplateRouterOptions) Run() error {
206208
BindPortsAfterSync: o.BindPortsAfterSync,
207209
IncludeUDP: o.RouterSelection.IncludeUDP,
208210
AllowWildcardRoutes: o.RouterSelection.AllowWildcardRoutes,
211+
MaxConnections: o.MaxConnections,
209212
}
210213

211214
oc, kc, err := o.Config.Clients()

pkg/router/template/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type TemplatePluginConfig struct {
5151
AllowWildcardRoutes bool
5252
PeerService *ktypes.NamespacedName
5353
BindPortsAfterSync bool
54+
MaxConnections string
5455
}
5556

5657
// routerInterface controls the interaction of the plugin with the underlying router implementation

test/cmd/router.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ os::cmd::expect_success_and_text 'oadm router --dry-run --host-network=false --h
4040
os::cmd::expect_success_and_text 'oadm router --dry-run --host-network=false --host-ports=false --router-canonical-hostname=1a.b.c.d -o yaml' '1a.b.c.d'
4141
os::cmd::expect_failure_and_text 'oadm router --dry-run --host-network=false --host-ports=false --router-canonical-hostname=1a._b.c.d -o yaml' 'error: invalid canonical hostname'
4242
os::cmd::expect_failure_and_text 'oadm router --dry-run --host-network=false --host-ports=false --router-canonical-hostname=1.2.3.4 -o yaml' 'error: canonical hostname must not be an IP address'
43+
# max_conn
44+
os::cmd::expect_success_and_text 'oadm router --dry-run --host-network=false --host-ports=false --max-connections=14583 -o yaml' '14583'
4345

4446
# mount tls crt as secret
4547
os::cmd::expect_success_and_not_text 'oadm router --dry-run --host-network=false --host-ports=false -o yaml' 'value: /etc/pki/tls/private/tls.crt'

0 commit comments

Comments
 (0)