Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add worker-cpu-affinity configmap key #193

Merged
merged 1 commit into from
Oct 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/customization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The table below summarizes some of the options. More options (extensions) are av
| `nginx.org/listen-ports` | N/A | Configures HTTP ports that NGINX will listen on. | `[80]` |
| `nginx.org/listen-ports-ssl` | N/A | Configures HTTPS ports that NGINX will listen on. | `[443]` |
| N/A | `worker-processes` | Sets the value of the [worker_processes](http://nginx.org/en/docs/ngx_core_module.html#worker_processes) directive. | `auto` |
| 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 |

## Using ConfigMaps

Expand Down
1 change: 1 addition & 0 deletions examples/customization/nginx-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ data:
proxy_temp_path /var/nginx/proxy_temp;
charset koi8-r;
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
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
3 changes: 3 additions & 0 deletions nginx-controller/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ func (lbc *LoadBalancerController) syncCfgm(task Task) {
cfg.MainWorkerProcesses = cfgm.Data["worker-processes"]
}
}
if workerCPUAffinity, exists := cfgm.Data["worker-cpu-affinity"]; exists {
cfg.MainWorkerCPUAffinity = workerCPUAffinity
}
}

var ingExes []*nginx.IngressEx
Expand Down
1 change: 1 addition & 0 deletions nginx-controller/nginx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Config struct {
HSTSIncludeSubdomains bool
LBMethod string
MainWorkerProcesses string
MainWorkerCPUAffinity string

// http://nginx.org/en/docs/http/ngx_http_realip_module.html
RealIPHeader string
Expand Down
9 changes: 5 additions & 4 deletions nginx-controller/nginx/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,11 @@ func (cnf *Configurator) UpdateConfig(config *Config, ingExes []*IngressEx) erro
SSLCiphers: config.MainServerSSLCiphers,
SSLDHParam: config.MainServerSSLDHParam,
SSLPreferServerCiphers: config.MainServerSSLPreferServerCiphers,
HTTP2: config.HTTP2,
ServerTokens: config.ServerTokens,
ProxyProtocol: config.ProxyProtocol,
WorkerProcesses: config.MainWorkerProcesses,
HTTP2: config.HTTP2,
ServerTokens: config.ServerTokens,
ProxyProtocol: config.ProxyProtocol,
WorkerProcesses: config.MainWorkerProcesses,
WorkerCPUAffinity: config.MainWorkerCPUAffinity,
}

cnf.nginx.UpdateMainConfigFile(mainCfg)
Expand Down
1 change: 1 addition & 0 deletions nginx-controller/nginx/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type NginxMainConfig struct {
ServerTokens string
ProxyProtocol bool
WorkerProcesses string
WorkerCPUAffinity string
}

// NewUpstreamWithDefaultServer creates an upstream with the default server.
Expand Down
2 changes: 2 additions & 0 deletions nginx-controller/nginx/templates/nginx-plus.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

user nginx;
worker_processes {{.WorkerProcesses}};
{{- if .WorkerCPUAffinity}}
worker_cpu_affinity {{.WorkerCPUAffinity}};{{end}}

daemon off;

Expand Down
2 changes: 2 additions & 0 deletions nginx-controller/nginx/templates/nginx.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

user nginx;
worker_processes {{.WorkerProcesses}};
{{- if .WorkerCPUAffinity}}
worker_cpu_affinity {{.WorkerCPUAffinity}};{{end}}

daemon off;

Expand Down
1 change: 1 addition & 0 deletions nginx-controller/nginx/templates/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var mainCfg = nginx.NginxMainConfig{
ServerNamesHashMaxSize: "512",
ServerTokens: "off",
WorkerProcesses: "auto",
WorkerCPUAffinity: "auto",
}

func TestIngressForNGINXPlus(t *testing.T) {
Expand Down