Skip to content

Commit b192fe9

Browse files
authored
Merge pull request #228 from Sarga/rlimit_nofile
Add worker-rlimit-nofile configmap key
2 parents b491961 + d924208 commit b192fe9

File tree

9 files changed

+13
-0
lines changed

9 files changed

+13
-0
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-rlimit-nofile` | Sets the value of the [worker_rlimit_nofile](http://nginx.org/en/docs/ngx_core_module.html#worker_rlimit_nofile) directive. | N/A |
4344
| N/A | `worker-connections` | Sets the value of the [worker_connections](http://nginx.org/en/docs/ngx_core_module.html#worker_connections) directive. | `1024` |
4445
| 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 |
4546
| 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 |

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-rlimit-nofile: "65536" # No default. Sets the value of the worker_rlimit_nofile directive. See http://nginx.org/en/docs/ngx_core_module.html#worker_rlimit_nofile
5152
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
5253
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
5354
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

nginx-controller/controller/controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,9 @@ func (lbc *LoadBalancerController) syncCfgm(task Task) {
598598
if workerConnections, exists := cfgm.Data["worker-connections"]; exists {
599599
cfg.MainWorkerConnections = workerConnections
600600
}
601+
if workerRlimitNofile, exists := cfgm.Data["worker-rlimit-nofile"]; exists {
602+
cfg.MainWorkerRlimitNofile = workerRlimitNofile
603+
}
601604
if keepalive, exists, err := nginx.GetMapKeyAsInt(cfgm.Data, "keepalive", cfgm); exists {
602605
if err != nil {
603606
glog.Error(err)

nginx-controller/nginx/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Config struct {
3131
MainWorkerCPUAffinity string
3232
MainWorkerShutdownTimeout string
3333
MainWorkerConnections string
34+
MainWorkerRlimitNofile string
3435
Keepalive int64
3536

3637
// http://nginx.org/en/docs/http/ngx_http_realip_module.html

nginx-controller/nginx/configurator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ func (cnf *Configurator) UpdateConfig(config *Config, ingExes []*IngressEx) erro
710710
WorkerCPUAffinity: config.MainWorkerCPUAffinity,
711711
WorkerShutdownTimeout: config.MainWorkerShutdownTimeout,
712712
WorkerConnections: config.MainWorkerConnections,
713+
WorkerRlimitNofile: config.MainWorkerRlimitNofile,
713714
}
714715

715716
cnf.nginx.UpdateMainConfigFile(mainCfg)

nginx-controller/nginx/nginx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ type NginxMainConfig struct {
120120
WorkerCPUAffinity string
121121
WorkerShutdownTimeout string
122122
WorkerConnections string
123+
WorkerRlimitNofile string
123124
}
124125

125126
// NewUpstreamWithDefaultServer creates an upstream with the default server.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
user nginx;
33
worker_processes {{.WorkerProcesses}};
4+
{{- if .WorkerRlimitNofile}}
5+
worker_rlimit_nofile {{.WorkerRlimitNofile}};{{end}}
46
{{- if .WorkerCPUAffinity}}
57
worker_cpu_affinity {{.WorkerCPUAffinity}};{{end}}
68
{{- if .WorkerShutdownTimeout}}

nginx-controller/nginx/templates/nginx.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
user nginx;
33
worker_processes {{.WorkerProcesses}};
4+
{{- if .WorkerRlimitNofile}}
5+
worker_rlimit_nofile {{.WorkerRlimitNofile}};{{end}}
46
{{- if .WorkerCPUAffinity}}
57
worker_cpu_affinity {{.WorkerCPUAffinity}};{{end}}
68
{{- if .WorkerShutdownTimeout}}

nginx-controller/nginx/templates/templates_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var mainCfg = nginx.NginxMainConfig{
5858
WorkerCPUAffinity: "auto",
5959
WorkerShutdownTimeout: "1m",
6060
WorkerConnections: "1024",
61+
WorkerRlimitNofile: "65536",
6162
}
6263

6364
func TestIngressForNGINXPlus(t *testing.T) {

0 commit comments

Comments
 (0)