From b4ac7ad5cace57fd457bbfe3caebd0de5f51523a Mon Sep 17 00:00:00 2001 From: Andrey Voronkov Date: Wed, 18 Dec 2019 19:31:57 +0300 Subject: [PATCH] [stable/redis-ha] Enable sticky connections balancing via HAProxy. (#19589) I just found that python Redis client (Sentry, Weblate) is having trouble with HAProxy + Redis HA scheme. It seems like HAProxy balance source + hash-type consistent does the trick. Signed-off-by: Andrey Voronkov --- stable/redis-ha/Chart.yaml | 2 +- stable/redis-ha/README.md | 1 + stable/redis-ha/templates/_configs.tpl | 8 ++++++++ stable/redis-ha/values.yaml | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/stable/redis-ha/Chart.yaml b/stable/redis-ha/Chart.yaml index 6d665cdc21..4411ab6aee 100644 --- a/stable/redis-ha/Chart.yaml +++ b/stable/redis-ha/Chart.yaml @@ -6,7 +6,7 @@ keywords: - redis - keyvalue - database -version: 4.1.6 +version: 4.2.0 appVersion: 5.0.6 description: Highly available Kubernetes implementation of Redis icon: https://upload.wikimedia.org/wikipedia/en/thumb/6/6b/Redis_Logo.svg/1200px-Redis_Logo.svg.png diff --git a/stable/redis-ha/README.md b/stable/redis-ha/README.md index 56ea52c202..1e471f632e 100644 --- a/stable/redis-ha/README.md +++ b/stable/redis-ha/README.md @@ -108,6 +108,7 @@ The following table lists the configurable parameters of the Redis chart and the | `haproxy.service.type` | HAProxy service type "ClusterIP", "LoadBalancer" or "NodePort" | `ClusterIP` | | `haproxy.service.nodePort` | HAProxy service nodePort value (haproxy.service.type must be NodePort) | not set | | `haproxy.service.annotations` | HAProxy service annotations | `{}` | +| `haproxy.stickyBalancing` | HAProxy sticky load balancing to Redis nodes. Helps with connections shutdown. | `false` | | `haproxy.hapreadport.enable` | Enable a read only port for redis slaves | `false` | | `haproxy.hapreadport.port` | Haproxy port for read only redis slaves | `6380` | | `haproxy.metrics.enabled` | HAProxy enable prometheus metric scraping | `false` | diff --git a/stable/redis-ha/templates/_configs.tpl b/stable/redis-ha/templates/_configs.tpl index f3ab4aecb2..1b502743d1 100644 --- a/stable/redis-ha/templates/_configs.tpl +++ b/stable/redis-ha/templates/_configs.tpl @@ -185,6 +185,10 @@ {{- end }} # Check all redis servers to see if they think they are master backend bk_redis_master + {{- if .Values.haproxy.stickyBalancing }} + balance source + hash-type consistent + {{- end }} mode tcp option tcp-check tcp-check connect @@ -204,6 +208,10 @@ {{- end }} {{- if .Values.haproxy.readOnly.enabled }} backend bk_redis_slave + {{- if .Values.haproxy.stickyBalancing }} + balance source + hash-type consistent + {{- end }} mode tcp option tcp-check tcp-check connect diff --git a/stable/redis-ha/values.yaml b/stable/redis-ha/values.yaml index 541a990abf..3e9132de8b 100644 --- a/stable/redis-ha/values.yaml +++ b/stable/redis-ha/values.yaml @@ -40,6 +40,9 @@ haproxy: pullPolicy: IfNotPresent annotations: {} resources: {} + ## Enable sticky sessions to Redis nodes via HAProxy + ## Very useful for long-living connections as in case of Sentry for example + stickyBalancing: false ## Kubernetes priorityClass name for the haproxy pod # priorityClassName: "" ## Service type for HAProxy