From ffef3f2f2d8791c148933de480a4f510e5acbaee Mon Sep 17 00:00:00 2001 From: Alex Lundberg <34074700+lundbird@users.noreply.github.com> Date: Tue, 19 Nov 2019 01:11:41 -0500 Subject: [PATCH] [stable/redis-ha] Add haproxy pod affinity rules to helm template. (#18936) * [stable/redis-ha] Implement haproxy pod affinity. (#18935) Signed-off-by: alex lundberg * [stable/redis-ha] Bump minor version number (#18935) Signed-off-by: alex lundberg * [stable/redis-ha] Add security context back in (#18935) Signed-off-by: alex lundberg --- stable/redis-ha/Chart.yaml | 2 +- stable/redis-ha/README.md | 5 ++- .../templates/redis-haproxy-deployment.yaml | 34 +++++++++++++++++++ stable/redis-ha/values.yaml | 10 ++++++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/stable/redis-ha/Chart.yaml b/stable/redis-ha/Chart.yaml index eccd727e55..c9acb73524 100644 --- a/stable/redis-ha/Chart.yaml +++ b/stable/redis-ha/Chart.yaml @@ -6,7 +6,7 @@ keywords: - redis - keyvalue - database -version: 4.0.3 +version: 4.0.4 appVersion: 5.0.5 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 cfde236308..419cb00feb 100644 --- a/stable/redis-ha/README.md +++ b/stable/redis-ha/README.md @@ -97,7 +97,7 @@ The following table lists the configurable parameters of the Redis chart and the | `exporter.serviceMonitor.labels` | Labels for the servicemonitor passed to Prometheus Operator | `{}` | | `exporter.serviceMonitor.timeout` | How long until a scrape request times out. If not set, the Prometheus default scape timeout is used | `nil` | | `haproxy.enabled` | Enabled HAProxy LoadBalancing/Proxy | `false` | -| `haproxy.replicas` | Number of HAProxy instances | `1` | +| `haproxy.replicas` | Number of HAProxy instances | `3` | | `haproxy.image.repository`| HAProxy Image Repository | `haproxy` | | `haproxy.image.tag` | HAProxy Image Tag | `2.0.1` | | `haproxy.image.pullPolicy`| HAProxy Image PullPolicy | `IfNotPresent` | @@ -120,6 +120,9 @@ The following table lists the configurable parameters of the Redis chart and the | `haproxy.timeout.client` | haproxy.cfg `timeout client` setting | `30s` | | `haproxy.priorityClassName` | priorityClassName for `haproxy` deployment | not set | | `haproxy.securityContext` | Security context to be added to the HAProxy deployment. | `{runAsUser: 1000, fsGroup: 1000, runAsNonRoot: true}` | +| `haproxy.hardAntiAffinity` | Whether the haproxy pods should be forced to run on separate nodes. | `true` | +| `haproxy.affinity` | Override all other haproxy affinity settings with a string. | `""` | +| `haproxy.additionalAffinities` | Additional affinities to add to the haproxy server pods. | `{}` | | `podDisruptionBudget` | Pod Disruption Budget rules | `{}` | | `priorityClassName` | priorityClassName for `redis-ha-statefulset` | not set | | `hostPath.path` | Use this path on the host for data storage | not set | diff --git a/stable/redis-ha/templates/redis-haproxy-deployment.yaml b/stable/redis-ha/templates/redis-haproxy-deployment.yaml index 5f0c743ca7..f7bf42f353 100644 --- a/stable/redis-ha/templates/redis-haproxy-deployment.yaml +++ b/stable/redis-ha/templates/redis-haproxy-deployment.yaml @@ -39,6 +39,40 @@ spec: {{ toYaml .Values.nodeSelector | indent 8 }} tolerations: {{ toYaml .Values.tolerations | indent 8 }} + affinity: + {{- if .Values.haproxy.affinity }} + {{- with .Values.haproxy.affinity }} +{{ tpl . $ | indent 8 }} + {{- end }} + {{- else }} + {{- if .Values.haproxy.additionalAffinities }} +{{ toYaml .Values.haproxy.additionalAffinities | indent 8 }} + {{- end }} + podAntiAffinity: + {{- if .Values.haproxy.hardAntiAffinity }} + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchLabels: + app: {{ template "redis-ha.name" . }}-haproxy + release: {{ .Release.Name }} + topologyKey: kubernetes.io/hostname + {{- else }} + preferredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchLabels: + app: {{ template "redis-ha.name" . }}-haproxy + release: {{ .Release.Name }} + topologyKey: kubernetes.io/hostname + {{- end }} + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchLabels: + app: {{ template "redis-ha.name" . }}-haproxy + release: {{ .Release.Name }} + topologyKey: failure-domain.beta.kubernetes.io/zone + {{- end }} initContainers: - name: config-init image: {{ .Values.haproxy.image.repository }}:{{ .Values.haproxy.image.tag }} diff --git a/stable/redis-ha/values.yaml b/stable/redis-ha/values.yaml index e17e05cfdd..467256583f 100644 --- a/stable/redis-ha/values.yaml +++ b/stable/redis-ha/values.yaml @@ -69,6 +69,16 @@ haproxy: runAsUser: 1000 fsGroup: 1000 runAsNonRoot: true + + ## Whether the haproxy pods should be forced to run on separate nodes. + hardAntiAffinity: true + + ## Additional affinities to add to the haproxy pods. + additionalAffinities: {} + + ## Override all other affinity settings for the haproxy pods with a string. + affinity: | + ## Custom config-haproxy.cfg files used to override default settings. If this file is ## specified then the config-haproxy.cfg above will be ignored. ##