Added new affinity mode for maximum session stickyness. Fixes kubernetes/ingress-nginx#4475

This commit is contained in:
Alexander Maret-Huskinson 2019-08-30 11:40:29 +02:00
parent 8740c1b661
commit 9170591185
16 changed files with 541 additions and 55 deletions

View file

@ -28,6 +28,7 @@ import (
const (
annotationAffinityType = "affinity"
annotationAffinityMode = "affinity-mode"
// If a cookie with this name exists,
// its value is used as an index into the list of available backends.
annotationAffinityCookieName = "session-cookie-name"
@ -57,6 +58,8 @@ var (
type Config struct {
// The type of affinity that will be used
Type string `json:"type"`
// The affinity mode, i.e. how sticky a session is
Mode string `json:"mode"`
Cookie
}
@ -136,6 +139,12 @@ func (a affinity) Parse(ing *networking.Ingress) (interface{}, error) {
at = ""
}
// Check the afinity mode that will be used
am, err := parser.GetStringAnnotation(annotationAffinityMode, ing)
if err != nil {
am = ""
}
switch at {
case "cookie":
cookie = a.cookieAffinityParse(ing)
@ -146,6 +155,7 @@ func (a affinity) Parse(ing *networking.Ingress) (interface{}, error) {
return &Config{
Type: at,
Mode: am,
Cookie: *cookie,
}, nil
}