Skip to content

Commit

Permalink
stable work haproxy with redis
Browse files Browse the repository at this point in the history
  • Loading branch information
wirwolf committed Jan 30, 2024
1 parent 7688ef7 commit af15d29
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 89 deletions.
2 changes: 1 addition & 1 deletion charts/redis-high-availability/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: redis high availability
name: redis-high-availability
version: 0.2.0
version: 0.2.1
dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
Expand Down
6 changes: 0 additions & 6 deletions charts/redis-high-availability/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,3 @@ Define the chart version
{{- define "haproxy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }}
{{- end }}
{{/*
Create Redis backend server address.
*/}}
{{- define "haproxy.redisBackendAddress" -}}
_tcp-redis._tcp.redis-headless.{{ $.Release.Namespace }}.svc.{{ $.Values.configmap.redis.clusterDomain }}:6379
{{- end }}
14 changes: 8 additions & 6 deletions charts/redis-high-availability/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,28 @@ data:
bind *:{{ .Values.configmap.frontend.redisWritePort }}
default_backend redis-primary
backend redis-primary
backend redis-primary
mode tcp
balance {{ .Values.configmap.backend.balanceAlgorithm }}
option tcp-smart-connect
option tcpka
option tcp-check
tcp-check send AUTH\ {{ .Values.configmap.redis.auth }}\r\n
{{- if $.Values.redis.auth.enabled }}
tcp-check send AUTH\ {{ $.Values.redis.auth.password }}\r\n
{{- end }}
tcp-check expect string +OK
tcp-check send info\ replication\r\n
tcp-check expect string role:master
{{- range $i := until (int .Values.configmap.backend.redisServerCount) }}
server redis-node-{{ $i }} app-redis-node-{{ $i }}.{{ $.Values.configmap.redis.headlessServiceName }}.{{ $.Release.Namespace }}.svc.{{ $.Values.configmap.redis.clusterDomain }}:6379 check inter 1s rise 2 fall 2
{{- range $i := until (int $.Values.redis.replica.replicaCount) }}
server redis-node-{{ $i }} {{ $.Release.Name }}-node-{{ $i }}.{{ $.Release.Name }}-headless.{{ $.Release.Namespace }}.svc.{{ $.Values.clusterDomain }}:6379 check inter 1s rise 30 fall 2
{{- end }}
backend redis-online
mode tcp
balance {{ .Values.configmap.backend.balanceAlgorithm }}
{{- range $i := until (int .Values.configmap.backend.redisServerCount) }}
server redis-node-{{ $i }} app-redis-node-{{ $i }}.{{ $.Values.configmap.redis.headlessServiceName }}.{{ $.Release.Namespace }}.svc.{{ $.Values.configmap.redis.clusterDomain }}:6379 check inter 1s rise 2 fall 2
{{- range $i := until (int $.Values.redis.replica.replicaCount) }}
server redis-node-{{ $i }} {{ $.Release.Name }}-node-{{ $i }}.{{ $.Release.Name }}-headless.{{ $.Release.Namespace }}.svc.{{ $.Values.clusterDomain }}:6379 check inter 1s rise 30 fall 2
{{- end }}
2 changes: 1 addition & 1 deletion charts/redis-high-availability/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "haproxy.fullname" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "haproxy.labels" . | nindent 4 }}
spec:
Expand All @@ -14,6 +13,7 @@ spec:
metadata:
labels:
app: {{ include "haproxy.name" . }}
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
spec:
{{- with .Values.affinity }}
affinity:
Expand Down
1 change: 0 additions & 1 deletion charts/redis-high-availability/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "haproxy.fullname" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "haproxy.labels" . | nindent 4 }}
spec:
Expand Down
78 changes: 4 additions & 74 deletions charts/redis-high-availability/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace: namespace
replicaCount: 2
replicaCount: 1

clusterDomain: "cluster.local"

image:
repository: haproxy
tag: 2.3
tag: 2.9

service:
type: ClusterIP
Expand All @@ -30,14 +31,6 @@ configmap:
uri: "/"
refresh: "1s"
admin: "TRUE"
redis:
auth: "redis_pass"
clusterDomain: "cluster.local"
prefix: app-redis-node
headlessServiceName: app-redis-headless

defaultSettings:
optionRedispatch: true

frontend:
redisReadPort: 6380
Expand Down Expand Up @@ -66,73 +59,10 @@ affinity:
- haproxy
topologyKey: "kubernetes.io/hostname"
redis:
image:
registry: docker.io
repository: bitnami/redis
tag: 6.2.5-debian-10-r63

clusterDomain: "cluster.local"

## @param architecture Redis(TM) architecture. Allowed values: `standalone` or `replication`
##
architecture: replication


## Redis(TM) Authentication parameters
## ref: https://github.com/bitnami/bitnami-docker-redis#setting-the-server-password-on-first-run
##
auth:
## @param auth.password Redis™ password
## Defaults to a random 10-character alphanumeric string if not set
##
password: "redis_pass"

master:
count: 1
persistence:
## @param master.persistence.enabled Enable persistence on Redis™ master nodes using Persistent Volume Claims
##
enabled: false

livenessProbe:
enabled: true
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 30
readinessProbe:
enabled: true
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 1
successThreshold: 1

replica:
## @param replica.replicaCount Number of Redis(TM) replicas to deploy
##
replicaCount: 3
persistence:
enabled: false

sentinel:
enabled: true
image:
registry: docker.io
repository: bitnami/redis-sentinel
tag: 6.2.5-debian-10-r63
getMasterTimeout: 15

livenessProbe:
enabled: true
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 30
readinessProbe:
enabled: true
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 1
successThreshold: 1

0 comments on commit af15d29

Please # to comment.