Skip to content

Commit b491961

Browse files
authored
Merge pull request #223 from Sarga/master
Add worker-connections configmap key
2 parents 9eda836 + a521e6c commit b491961

File tree

9 files changed

+13
-2
lines changed

9 files changed

+13
-2
lines changed

examples/customization/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The table below summarizes some of the options. More options (extensions) are av
4040
| `nginx.org/listen-ports` | N/A | Configures HTTP ports that NGINX will listen on. | `[80]` |
4141
| `nginx.org/listen-ports-ssl` | N/A | Configures HTTPS ports that NGINX will listen on. | `[443]` |
4242
| N/A | `worker-processes` | Sets the value of the [worker_processes](http://nginx.org/en/docs/ngx_core_module.html#worker_processes) directive. | `auto` |
43+
| N/A | `worker-connections` | Sets the value of the [worker_connections](http://nginx.org/en/docs/ngx_core_module.html#worker_connections) directive. | `1024` |
4344
| N/A | `worker-cpu-affinity` | Sets the value of the [worker_cpu_affinity](http://nginx.org/en/docs/ngx_core_module.html#worker_cpu_affinity) directive. | N/A |
4445
| N/A | `worker-shutdown-timeout` | Sets the value of the [worker_shutdown_timeout](http://nginx.org/en/docs/ngx_core_module.html#worker_shutdown_timeout) directive. | N/A |
4546
| `nginx.org/keepalive` | `keepalive` | Sets the value of the [keepalive](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive) directive. Note that `proxy_set_header Connection "";` is added to the generated configuration when the value > 0. | `0` |

examples/customization/nginx-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ data:
4848
proxy_temp_path /var/nginx/proxy_temp;
4949
charset koi8-r;
5050
worker-processes: "1" # default is "auto". Sets the value of the worker_processes directive. See http://nginx.org/en/docs/ngx_core_module.html#worker_processes
51+
worker-connections: "10240" # default is "1024". Sets the value of the worker_connections directive. See http://nginx.org/en/docs/ngx_core_module.html#worker_connections
5152
worker-cpu-affinity: "auto" # No default. Sets the value of the worker_cpu_affinity directive. See http://nginx.org/en/docs/ngx_core_module.html#worker_cpu_affinity
5253
worker-shutdown-timeout: "5m" # No default. Sets the value of the worker_shutdown_timeout directive. See http://nginx.org/en/docs/ngx_core_module.html#worker_shutdown_timeout
5354
keepalive: "32" # default is 0. When > 0, sets the value of the keepalive directive and adds 'proxy_set_header Connection "";' to a location block. See http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive

nginx-controller/controller/controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ func (lbc *LoadBalancerController) syncCfgm(task Task) {
595595
if workerShutdownTimeout, exists := cfgm.Data["worker-shutdown-timeout"]; exists {
596596
cfg.MainWorkerShutdownTimeout = workerShutdownTimeout
597597
}
598+
if workerConnections, exists := cfgm.Data["worker-connections"]; exists {
599+
cfg.MainWorkerConnections = workerConnections
600+
}
598601
if keepalive, exists, err := nginx.GetMapKeyAsInt(cfgm.Data, "keepalive", cfgm); exists {
599602
if err != nil {
600603
glog.Error(err)

nginx-controller/nginx/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type Config struct {
3030
MainWorkerProcesses string
3131
MainWorkerCPUAffinity string
3232
MainWorkerShutdownTimeout string
33+
MainWorkerConnections string
3334
Keepalive int64
3435

3536
// http://nginx.org/en/docs/http/ngx_http_realip_module.html
@@ -63,6 +64,7 @@ func NewDefaultConfig() *Config {
6364
MainServerNamesHashMaxSize: "512",
6465
ProxyBuffering: true,
6566
MainWorkerProcesses: "auto",
67+
MainWorkerConnections: "1024",
6668
HSTSMaxAge: 2592000,
6769
Ports: []int{80},
6870
SSLPorts: []int{443},

nginx-controller/nginx/configurator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ func (cnf *Configurator) UpdateConfig(config *Config, ingExes []*IngressEx) erro
709709
WorkerProcesses: config.MainWorkerProcesses,
710710
WorkerCPUAffinity: config.MainWorkerCPUAffinity,
711711
WorkerShutdownTimeout: config.MainWorkerShutdownTimeout,
712+
WorkerConnections: config.MainWorkerConnections,
712713
}
713714

714715
cnf.nginx.UpdateMainConfigFile(mainCfg)

nginx-controller/nginx/nginx.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ type NginxMainConfig struct {
119119
WorkerProcesses string
120120
WorkerCPUAffinity string
121121
WorkerShutdownTimeout string
122+
WorkerConnections string
122123
}
123124

124125
// NewUpstreamWithDefaultServer creates an upstream with the default server.
@@ -146,6 +147,7 @@ func NewNginxController(nginxConfPath string, local bool, healthStatus bool, ngi
146147
ServerNamesHashMaxSize: NewDefaultConfig().MainServerNamesHashMaxSize,
147148
ServerTokens: NewDefaultConfig().ServerTokens,
148149
WorkerProcesses: NewDefaultConfig().MainWorkerProcesses,
150+
WorkerConnections: NewDefaultConfig().MainWorkerConnections,
149151
}
150152
ngxc.UpdateMainConfigFile(cfg)
151153

nginx-controller/nginx/templates/nginx-plus.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pid /var/run/nginx.pid;
1717
{{- end}}
1818

1919
events {
20-
worker_connections 1024;
20+
worker_connections {{.WorkerConnections}};
2121
}
2222

2323

nginx-controller/nginx/templates/nginx.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pid /var/run/nginx.pid;
1616
{{- end}}
1717

1818
events {
19-
worker_connections 1024;
19+
worker_connections {{.WorkerConnections}};
2020
}
2121

2222

nginx-controller/nginx/templates/templates_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var mainCfg = nginx.NginxMainConfig{
5757
WorkerProcesses: "auto",
5858
WorkerCPUAffinity: "auto",
5959
WorkerShutdownTimeout: "1m",
60+
WorkerConnections: "1024",
6061
}
6162

6263
func TestIngressForNGINXPlus(t *testing.T) {

0 commit comments

Comments
 (0)