Skip to content

Commit fcb1b30

Browse files
stable/redis-ha: Helm templates in provided secret names. (#253)
* feat: Helm templates in provided secret names. Added support for helm templates in the following entries: * `.existingSecret` * `.sentinel.existingSecret` * `.haproxy.tls.secretName` * `.tls.secretName` Signed-off-by: Pavel Jancik <pavel.jancik@themama.ai> Signed-off-by: Pavel Jancik <pavel.jancik@thremama.ai> Signed-off-by: Aaron Layfield <aaron.layfield@gmail.com> Co-authored-by: Aaron Layfield <aaron.layfield@gmail.com>
1 parent d4f5cee commit fcb1b30

9 files changed

Lines changed: 44 additions & 35 deletions

charts/redis-ha/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ keywords:
55
- redis
66
- keyvalue
77
- database
8-
version: 4.34.11
8+
version: 4.34.12
99
appVersion: 8.2.1
1010
description: This Helm chart provides a highly available Redis implementation with a master/slave configuration and uses Sentinel sidecars for failover management
1111
icon: https://img.icons8.com/external-tal-revivo-shadow-tal-revivo/24/external-redis-an-in-memory-data-structure-project-implementing-a-distributed-logo-shadow-tal-revivo.png

charts/redis-ha/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ The following table lists the configurable parameters of the Redis chart and the
133133
| `redis.livenessProbe.successThreshold` | Success threshold for liveness probe | int | `1` |
134134
| `redis.livenessProbe.timeoutSeconds` | Timeout seconds for liveness probe | int | `15` |
135135
| `redis.masterGroupName` | Redis convention for naming the cluster group: must match `^[\\w-\\.]+$` and can be templated | string | `"mymaster"` |
136+
| `redis.minReadySeconds` | Configure the 'minReadySeconds' parameter to StatefulSet ref: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#minreadyseconds | int | `0` |
136137
| `redis.podAnnotations` | Annotations to be added to the redis statefulset pods | object | `{}` |
137138
| `redis.port` | Port to access the redis service | int | `6379` |
138139
| `redis.readinessProbe` | Readiness probe parameters for redis container | object | `{"enabled":true,"failureThreshold":5,"initialDelaySeconds":30,"periodSeconds":15,"successThreshold":1,"timeoutSeconds":15}` |

charts/redis-ha/templates/redis-auth-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.auth (not .Values.existingSecret) -}}
1+
{{- if and .Values.auth (not (tpl (.Values.existingSecret | default "" ) . )) -}}
22
{{ $fullAnnotations := mustMerge .Values.redis.annotations .Values.authSecretAnnotations }}
33
apiVersion: v1
44
kind: Secret

charts/redis-ha/templates/redis-ha-serviceaccount.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ metadata:
2020
secrets:
2121
{{- end }}
2222
{{- if .Values.auth }}
23-
- name: {{ default (include "redis-ha.fullname" .) .Values.existingSecret }}
23+
- name: {{ default (include "redis-ha.fullname" .) (tpl (.Values.existingSecret | default "" ) . ) }}
2424
{{- end }}
2525
{{- if .Values.sentinel.auth }}
26-
- name: {{ default (printf "%s-sentinel" (include "redis-ha.fullname" .)) .Values.sentinel.existingSecret }}
26+
- name: {{ default (printf "%s-sentinel" (include "redis-ha.fullname" .)) (tpl (.Values.sentinel.existingSecret | default "" ) . ) }}
2727
{{- end }}
2828
{{- if .Values.imagePullSecrets }}
2929
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 0 }}

charts/redis-ha/templates/redis-ha-statefulset.yaml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ spec:
3232
metadata:
3333
annotations:
3434
checksum/init-config: {{ print (include "config-redis.conf" .) (include "config-sentinel.conf" .) (include "config-init.sh" .) (include "fix-split-brain.sh" .) (include "redis_liveness.sh" .) (include "redis_readiness.sh" .) (include "sentinel_liveness.sh" .) (include "trigger-failover-if-master.sh" .)| sha256sum }}
35-
{{- if .Values.podAnnotations }}
36-
{{ toYaml .Values.podAnnotations | indent 8 }}
35+
{{- if .Values.redis.podAnnotations }}
36+
{{ toYaml .Values.redis.podAnnotations | indent 8 }}
3737
{{- end }}
3838
{{- if and (.Values.exporter.enabled) (not .Values.exporter.serviceMonitor.enabled) }}
3939
prometheus.io/port: "{{ .Values.exporter.port }}"
@@ -158,8 +158,8 @@ spec:
158158
- name: AUTH
159159
valueFrom:
160160
secretKeyRef:
161-
{{- if .Values.existingSecret }}
162-
name: {{ .Values.existingSecret }}
161+
{{- if tpl (.Values.existingSecret | default "" ) . }}
162+
name: {{ tpl (.Values.existingSecret | default "" ) . }}
163163
{{- else }}
164164
name: {{ template "redis-ha.fullname" . }}
165165
{{- end }}
@@ -169,8 +169,8 @@ spec:
169169
- name: SENTINELAUTH
170170
valueFrom:
171171
secretKeyRef:
172-
{{- if .Values.sentinel.existingSecret }}
173-
name: {{ .Values.sentinel.existingSecret }}
172+
{{- if tpl (.Values.sentinel.existingSecret | default "" ) . }}
173+
name: {{ tpl (.Values.sentinel.existingSecret | default "" ) . }}
174174
{{- else }}
175175
name: {{ template "redis-ha.fullname" . }}-sentinel
176176
{{- end }}
@@ -205,7 +205,7 @@ spec:
205205
envFrom:
206206
- secretRef:
207207
{{- if .Values.restore.existingSecret }}
208-
name: {{ .Values.existingSecret }}
208+
name: {{ tpl (.Values.existingSecret | default "" ) . }}
209209
{{- else }}
210210
name: {{ include "redis-ha.fullname" . }}-secret
211211
{{- end }}
@@ -239,7 +239,7 @@ spec:
239239
envFrom:
240240
- secretRef:
241241
{{- if .Values.restore.existingSecret }}
242-
name: {{ .Values.existingSecret }}
242+
name: {{ tpl (.Values.existingSecret | default "" ) . }}
243243
{{- else }}
244244
name: {{ include "redis-ha.fullname" . }}-secret
245245
{{- end }}
@@ -269,7 +269,7 @@ spec:
269269
{{- if .Values.restore.existingSecret }}
270270
envFrom:
271271
- secretRef:
272-
name: {{ .Values.existingSecret }}
272+
name: {{ tpl (.Values.existingSecret | default "" ) . }}
273273
{{- end }}
274274
volumeMounts:
275275
- name: data
@@ -300,8 +300,8 @@ spec:
300300
- name: AUTH
301301
valueFrom:
302302
secretKeyRef:
303-
{{- if .Values.existingSecret }}
304-
name: {{ .Values.existingSecret }}
303+
{{- if tpl (.Values.existingSecret | default "" ) . }}
304+
name: {{ tpl (.Values.existingSecret | default "" ) . }}
305305
{{- else }}
306306
name: {{ template "redis-ha.fullname" . }}
307307
{{- end }}
@@ -400,8 +400,8 @@ spec:
400400
- name: AUTH
401401
valueFrom:
402402
secretKeyRef:
403-
{{- if .Values.existingSecret }}
404-
name: {{ .Values.existingSecret }}
403+
{{- if tpl (.Values.existingSecret | default "" ) . }}
404+
name: {{ tpl (.Values.existingSecret | default "" ) . }}
405405
{{- else }}
406406
name: {{ template "redis-ha.fullname" . }}
407407
{{- end }}
@@ -411,8 +411,8 @@ spec:
411411
- name: SENTINELAUTH
412412
valueFrom:
413413
secretKeyRef:
414-
{{- if .Values.sentinel.existingSecret }}
415-
name: {{ .Values.sentinel.existingSecret }}
414+
{{- if tpl (.Values.sentinel.existingSecret | default "" ) . }}
415+
name: {{ tpl (.Values.sentinel.existingSecret | default "" ) . }}
416416
{{- else }}
417417
name: {{ template "redis-ha.fullname" . }}-sentinel
418418
{{- end }}
@@ -502,8 +502,8 @@ spec:
502502
- name: AUTH
503503
valueFrom:
504504
secretKeyRef:
505-
{{- if .Values.existingSecret }}
506-
name: {{ .Values.existingSecret }}
505+
{{- if tpl (.Values.existingSecret | default "" ) . }}
506+
name: {{ tpl (.Values.existingSecret | default "" ) . }}
507507
{{- else }}
508508
name: {{ template "redis-ha.fullname" . }}
509509
{{- end }}
@@ -513,8 +513,8 @@ spec:
513513
- name: SENTINELAUTH
514514
valueFrom:
515515
secretKeyRef:
516-
{{- if .Values.sentinel.existingSecret }}
517-
name: {{ .Values.sentinel.existingSecret }}
516+
{{- if tpl (.Values.sentinel.existingSecret | default "" ) . }}
517+
name: {{ tpl (.Values.sentinel.existingSecret | default "" ) . }}
518518
{{- else }}
519519
name: {{ template "redis-ha.fullname" . }}-sentinel
520520
{{- end }}
@@ -553,8 +553,8 @@ spec:
553553
- name: REDIS_PASSWORD
554554
valueFrom:
555555
secretKeyRef:
556-
{{- if .Values.existingSecret }}
557-
name: {{ .Values.existingSecret }}
556+
{{- if tpl (.Values.existingSecret | default "" ) . }}
557+
name: {{ tpl (.Values.existingSecret | default "" ) . }}
558558
{{- else }}
559559
name: {{ template "redis-ha.fullname" . }}
560560
{{- end }}
@@ -617,8 +617,8 @@ spec:
617617
{{- if .Values.redis.tlsPort }}
618618
- name: tls-certs
619619
secret:
620-
{{- if .Values.tls.secretName }}
621-
secretName: {{ .Values.tls.secretName }}
620+
{{- if tpl (.Values.tls.secretName | default "" ) . }}
621+
secretName: {{ tpl (.Values.tls.secretName | default "" ) . }}
622622
{{- else }}
623623
secretName: {{ template "redis-ha.fullname" . }}-tls-secret
624624
{{- end }}

charts/redis-ha/templates/redis-haproxy-deployment.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ spec:
136136
- name: AUTH
137137
valueFrom:
138138
secretKeyRef:
139-
{{- if .Values.existingSecret }}
140-
name: {{ .Values.existingSecret }}
139+
{{- if tpl (.Values.existingSecret | default "" ) . }}
140+
name: {{ tpl (.Values.existingSecret | default "" ) . }}
141141
{{- else }}
142142
name: {{ template "redis-ha.fullname" . }}
143143
{{- end }}
@@ -147,8 +147,8 @@ spec:
147147
- name: SENTINELAUTH
148148
valueFrom:
149149
secretKeyRef:
150-
{{- if .Values.sentinel.existingSecret }}
151-
name: {{ .Values.sentinel.existingSecret }}
150+
{{- if tpl (.Values.sentinel.existingSecret | default "" ) . }}
151+
name: {{ tpl (.Values.sentinel.existingSecret | default "" ) . }}
152152
{{- else }}
153153
name: {{ template "redis-ha.fullname" . }}-sentinel
154154
{{- end }}
@@ -200,7 +200,7 @@ spec:
200200
{{- if .Values.haproxy.tls.enabled }}
201201
- name: pemfile
202202
secret:
203-
secretName: {{ .Values.haproxy.tls.secretName }}
203+
secretName: {{ tpl .Values.haproxy.tls.secretName . }}
204204
{{- end }}
205205
- name: config-volume
206206
configMap:

charts/redis-ha/templates/redis-tls-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.redis.tlsPort (not .Values.tls.secretName) -}}
1+
{{- if and .Values.redis.tlsPort (not (tpl (.Values.tls.secretName | default "" ) . )) -}}
22
apiVersion: v1
33
kind: Secret
44
metadata:

charts/redis-ha/templates/sentinel-auth-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.sentinel.auth (not .Values.sentinel.existingSecret) -}}
1+
{{- if and .Values.sentinel.auth (not (tpl ( .Values.sentinel.existingSecret | default "" ) . )) -}}
22
apiVersion: v1
33
kind: Secret
44
metadata:

charts/redis-ha/values.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ haproxy:
103103
# -- If "true" this will enable TLS termination on haproxy
104104
enabled: false
105105
# -- Secret containing the .pem file
106+
# Supports templates like "{{ .Release.Name }}-haproxy-tls"
106107
secretName: ""
107108
# -- Key file name
108109
keyName:
@@ -375,6 +376,10 @@ redis:
375376
# - secretRef:
376377
# name: add-env-secret
377378

379+
# -- Configure the 'minReadySeconds' parameter to StatefulSet
380+
# ref: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#minreadyseconds
381+
minReadySeconds: 0
382+
378383
## Configures redis with tls-port parameter
379384
# -- (int) TLS Port to access the redis service
380385
tlsPort: ~
@@ -529,6 +534,7 @@ sentinel:
529534

530535
# -- An existing secret containing a key defined by `sentinel.authKey` that configures `requirepass`
531536
# in the conf parameters (Requires `sentinel.auth: enabled`, cannot be used in conjunction with `.Values.sentinel.password`)
537+
# Supports templates like "{{ .Release.Name }}-sentinel-creds"
532538
existingSecret: ""
533539

534540
## Defines the key holding the sentinel password in existing secret.
@@ -852,6 +858,7 @@ authSecretAnnotations: {}
852858

853859
## Use existing secret containing key `authKey` (ignores redisPassword)
854860
## Can also store AWS S3 or SSH secrets in this secret
861+
## Supports templates like "{{ .Release.Name }}-creds"
855862
# -- An existing secret containing a key defined by `authKey` that configures `requirepass` and `masterauth` in the conf
856863
# parameters (Requires `auth: enabled`, cannot be used in conjunction with `.Values.redisPassword`)
857864
existingSecret: ~
@@ -905,7 +912,8 @@ emptyDir: {}
905912
tls:
906913
## Fill the name of secret if you want to use your own TLS certificates.
907914
## The secret should contains keys named by "tls.certFile" - the certificate, "tls.keyFile" - the private key, "tls.caCertFile" - the certificate of CA and "tls.dhParamsFile" - the dh parameter file
908-
## These secret will be genrated using files from certs folder if the secretName is not set and redis.tlsPort is set
915+
## Supports templates like "{{ .Release.Name }}-tls"
916+
## This secret will be generated using files from certs folder if the secretName is not set and redis.tlsPort is set
909917
# secretName: tls-secret
910918

911919
# -- Name of certificate file

0 commit comments

Comments
 (0)