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

Added upstream zone directive annotation #629

Merged
merged 7 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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 docs/configmap-and-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ spec:
| `nginx.org/websocket-services` | N/A | Enables WebSocket for services. | N/A | [WebSocket support](../examples/websocket). |
| `nginx.org/max-fails` | `max-fails` | Sets the value of the [max_fails](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#max_fails) parameter of the `server` directive. | `1` | |
| `nginx.org/max-conns` | N\A | Sets the value of the [max_conns](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#max_conns) parameter of the `server` directive. | `0` | |
| `nginx.org/upstream-zone-size` | N\A | Sets the size of the shared memory [zone](https://nginx.org/en/docs/http/ngx_http_upstream_module.html?#zone). If this annotation is not present then the zone directive will not be set. | `N\A` | |
vrrs marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you missed #629 (comment) unless I'm mistaken?

| `nginx.org/fail-timeout` | `fail-timeout` | Sets the value of the [fail_timeout](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#fail_timeout) parameter of the `server` directive. | `10s` | |
| `nginx.com/sticky-cookie-services` | N/A | Configures session persistence. | N/A | [Session Persistence](../examples/session-persistence). |
| `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` | |
Expand Down
5 changes: 5 additions & 0 deletions internal/configs/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var minionInheritanceList = map[string]bool{
"nginx.org/proxy-buffers": true,
"nginx.org/proxy-buffer-size": true,
"nginx.org/proxy-max-temp-file-size": true,
"nginx.org/upstream-zone-size": true,
"nginx.org/location-snippets": true,
"nginx.org/lb-method": true,
"nginx.org/keepalive": true,
Expand Down Expand Up @@ -247,6 +248,10 @@ func parseAnnotations(ingEx *IngressEx, baseCfgParams *ConfigParams, isPlus bool
cfgParams.ProxyBufferSize = proxyBufferSize
}

if upstreamZoneSize, exists := ingEx.Ingress.Annotations["nginx.org/upstream-zone-size"]; exists {
cfgParams.UpstreamZoneSize = upstreamZoneSize
}

if proxyMaxTempFileSize, exists := ingEx.Ingress.Annotations["nginx.org/proxy-max-temp-file-size"]; exists {
cfgParams.ProxyMaxTempFileSize = proxyMaxTempFileSize
}
Expand Down
1 change: 1 addition & 0 deletions internal/configs/config_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type ConfigParams struct {
ProxyProtocol bool
ProxyHideHeaders []string
ProxyPassHeaders []string
UpstreamZoneSize string
HSTS bool
HSTSBehindProxy bool
HSTSMaxAge int64
Expand Down
1 change: 1 addition & 0 deletions internal/configs/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ func createUpstream(ingEx *IngressEx, name string, backend *extensions.IngressBa
}

ups.LBMethod = cfg.LBMethod
ups.UpstreamZoneSize = cfg.UpstreamZoneSize
return ups
}

Expand Down
1 change: 1 addition & 0 deletions internal/configs/version1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Upstream struct {
LBMethod string
Queue int64
QueueTimeout int64
UpstreamZoneSize string
}

// UpstreamServer describes a server in an NGINX upstream.
Expand Down
1 change: 1 addition & 0 deletions internal/configs/version1/nginx.ingress.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

{{range $upstream := .Upstreams}}
upstream {{$upstream.Name}} {
{{if $upstream.UpstreamZoneSize }}zone {{$upstream.Name}} {{$upstream.UpstreamZoneSize}};{{end}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{if $upstream.UpstreamZoneSize }}zone {{$upstream.Name}} {{$upstream.UpstreamZoneSize}};{{end}}
{{if $upstream.UpstreamZoneSize}}zone {{$upstream.Name}} {{$upstream.UpstreamZoneSize}};{{end}}

{{if $upstream.LBMethod }}{{$upstream.LBMethod}};{{end}}
{{range $server := $upstream.UpstreamServers}}
server {{$server.Address}}:{{$server.Port}} max_fails={{$server.MaxFails}} fail_timeout={{$server.FailTimeout}} max_conns={{$server.MaxConns}};{{end}}
Expand Down