Adds support for configuring stickness per Ingress

This commit is contained in:
Ricardo Pchevuzinske Katz 2017-02-10 12:24:16 -02:00
parent 79e186cb77
commit 6809319318
7 changed files with 112 additions and 15 deletions

View file

@ -51,6 +51,9 @@ The following annotations are supported:
|[ingress.kubernetes.io/upstream-max-fails](#custom-nginx-upstream-checks)|number|
|[ingress.kubernetes.io/upstream-fail-timeout](#custom-nginx-upstream-checks)|number|
|[ingress.kubernetes.io/whitelist-source-range](#whitelist-source-range)|CIDR|
|[ingress.kubernetes.io/sticky-enabled](#sticky-session)|true or false|
|[ingress.kubernetes.io/sticky-name](#sticky-session)|string|
|[ingress.kubernetes.io/sticky-hash](#sticky-session)|string|
@ -177,6 +180,20 @@ To configure this setting globally for all Ingress rules, the `whitelist-source-
Please check the [whitelist](examples/whitelist/README.md) example.
### Sticky Session
The annotation `ingress.kubernetes.io/sticky-enabled` enables stickness in all Upstreams of an Ingress. This way, a request will always be directed to the same upstream server.
You can also specify the name of the cookie that will be used to route the requests with the annotation `ingress.kubernetes.io/sticky-name`. The default is to create a cookie named 'route'.
The annotation `ingress.kubernetes.io/sticky-hash` defines which algorithm will be used to 'hash' the used upstream. Default value is `md5` and possible values are `md5`, `sha1` and `index`.
This feature is implemented by the third party module *nginx-sticky-module-ng* (https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng).
The workflow used to define which upstream server will be used is explained here: https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/raw/08a395c66e425540982c00482f55034e1fee67b6/docs/sticky.pdf
### **Allowed parameters in configuration ConfigMap**
**proxy-body-size:** Sets the maximum allowed size of the client request body. See NGINX [client_max_body_size](http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size).

View file

@ -186,7 +186,7 @@ http {
{{range $name, $upstream := $backends}}
upstream {{$upstream.Name}} {
{{ if $upstream.StickySession.Enabled }}
sticky hash={{$upstream.StickySession.Hash}} route={{$upstream.StickySession.Hash}} httponly;
sticky hash={{$upstream.StickySession.Hash}} name={{$upstream.StickySession.Name}} httponly;
{{ else }}
least_conn;
{{ end }}