Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
[stable/redis-ha] Add a dedicated port in haproxy for redis slaves (#…
Browse files Browse the repository at this point in the history
…16824)

* [stable/redis-ha] Add a dedicated port in haproxy for redis slaves

* [stable/redis-ha] Add a dedicated port in haproxy for redis slaves

Signed-off-by: Amal Soman <amalsoman10@gmail.com>

* [stable/redis-ha] Add a dedicated port in haproxy for redis slaves

* [stable/redis-ha] Add a dedicated port in haproxy for redis slaves

Signed-off-by: Amal Soman <amalsoman10@gmail.com>

* [stable/redis-ha] Add a dedicated port in haproxy for redis slaves

* [stable/redis-ha] Add a dedicated port in haproxy for redis slaves

Signed-off-by: Amal Soman <amalsoman10@gmail.com>
  • Loading branch information
amalsom10 authored and k8s-ci-robot committed Sep 9, 2019
1 parent 4e61eb2 commit 0e4b542
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
2 changes: 1 addition & 1 deletion stable/redis-ha/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords:
- redis
- keyvalue
- database
version: 3.7.5
version: 3.7.6
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
Expand Down
2 changes: 2 additions & 0 deletions stable/redis-ha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ The following table lists the configurable parameters of the Redis chart and the
| `haproxy.resources` | HAProxy resources | `{}` |
| `haproxy.service.type` | HAProxy service type "ClusterIP" or "LoadBalancer" | `ClusterIP` |
| `haproxy.service.annotations` | HAProxy service annotations | `{}` |
| `haproxy.hapreadport.enable` | Enable a read only port for redis slaves | `false` |
| `haproxy.hapreadport.port` | Haproxy port for read only redis slaves | `6380` |
| `haproxy.exporter.enabled`| Enable Prometheus metric scraping | `false` |
| `haproxy.exporter.port` | Prometheus metric scraping port | `9101` |
| `haproxy.init.resources` | Extra init resources | `{}` |
Expand Down
33 changes: 29 additions & 4 deletions stable/redis-ha/templates/redis-ha-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,18 @@ data:
{{- end }}

# decide redis backend to use
frontend ft_redis
#master
frontend ft_redis_master
bind *:6379
use_backend bk_redis

use_backend bk_redis_master
{{ if .Values.haproxy.readOnly.enabled }}
#slave
frontend ft_redis_slave
bind *:6380
use_backend bk_redis_slave
{{- end }}
# Check all redis servers to see if they think they are master
backend bk_redis
backend bk_redis_master
mode tcp
option tcp-check
tcp-check connect
Expand All @@ -199,7 +205,26 @@ data:
{{- range $i := until $replicas }}
use-server R{{ $i }} if { srv_is_up(R{{ $i }}) } { nbsrv(check_if_redis_is_master_{{ $i }}) ge 2 }
server R{{ $i }} {{ $fullName }}-announce-{{ $i }}:6379 check inter 1s fall 1 rise 1
{{- end }}
{{ if .Values.haproxy.readOnly.enabled }}
backend bk_redis_slave
mode tcp
option tcp-check
tcp-check connect
{{- if .Values.auth }}
tcp-check send AUTH\ {{ .Values.redisPassword }}\r\n
tcp-check expect string +OK
{{- end }}
tcp-check send PING\r\n
tcp-check expect string +PONG
tcp-check send info\ replication\r\n
tcp-check expect string role:slave
tcp-check send QUIT\r\n
tcp-check expect string +OK
{{- range $i := until $replicas }}
server R{{ $i }} {{ $fullName }}-announce-{{ $i }}:6379 check inter 1s fall 1 rise 1
{{- end }}
{{- end }}
{{- end }}
{{- end }}
haproxy_init.sh: |
Expand Down
7 changes: 6 additions & 1 deletion stable/redis-ha/templates/redis-haproxy-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ spec:
- name: redis
containerPort: {{ default "6379" .Values.redis.port }}
hostPort: 6379
{{- if .Values.haproxy.readOnly.enabled }}
- name: readonlyport
containerPort: {{ default "6380" .Values.haproxy.readOnly.port }}
hostPort: 6380
{{- end }}
resources:
{{ toYaml .Values.haproxy.resources | indent 10 }}
volumeMounts:
Expand All @@ -93,4 +98,4 @@ spec:
emptyDir: {}
- name: data
emptyDir: {}
{{- end }}
{{- end }}
8 changes: 7 additions & 1 deletion stable/redis-ha/templates/redis-haproxy-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ spec:
port: {{ .Values.redis.port }}
protocol: TCP
targetPort: redis
{{- if .Values.haproxy.readOnly.enabled }}
- name: haproxyreadonly
port: {{ .Values.haproxy.readOnly.port }}
protocol: TCP
targetPort: {{ .Values.haproxy.readOnly.port }}
{{- end }}
{{- if .Values.exporter.enabled }}
- name: exporter-port
port: {{ .Values.haproxy.exporter.port }}
Expand All @@ -25,4 +31,4 @@ spec:
selector:
release: {{ .Release.Name }}
app: {{ template "redis-ha.name" . }}-haproxy
{{- end }}
{{- end }}
5 changes: 5 additions & 0 deletions stable/redis-ha/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ serviceAccount:
## ref: https://cbonte.github.io/haproxy-dconv/1.9/intro.html
haproxy:
enabled: false
# Enable if you want a dedicated port in haproxy for redis-slaves
readOnly:
enabled: false
port: 6380
replicas: 1
image:
repository: haproxy
Expand Down Expand Up @@ -91,6 +95,7 @@ redis:
rdbcompression: "yes"
rdbchecksum: "yes"


## Custom redis.conf files used to override default settings. If this file is
## specified then the redis.config above will be ignored.
# customConfig: |-
Expand Down

0 comments on commit 0e4b542

Please sign in to comment.