1- {{- if or (not (eq .Values.architecture "replication")) (not .Values.sentinel.enabled) }}
1+ {{- if gt (int64 .Values.master.count) 0 -}}
2+ {{- if or (ne .Values.architecture "replication") (not .Values.sentinel.enabled) }}
23apiVersion : {{ include "common.capabilities.statefulset.apiVersion" . }}
34kind : {{ .Values.master.kind }}
45metadata :
56 name : {{ printf "%s-master" (include "common.names.fullname" .) }}
6- namespace : {{ .Release.Namespace | quote }}
7+ namespace : {{ include "common.names.namespace" . | quote }}
78 labels : {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
89 app.kubernetes.io/component : master
910 {{- if .Values.commonAnnotations }}
1011 annotations : {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
1112 {{- end }}
1213spec :
1314 replicas : {{ .Values.master.count }}
15+ revisionHistoryLimit : {{ .Values.master.revisionHistoryLimit }}
1416 {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.master.podLabels .Values.commonLabels ) "context" . ) }}
1517 selector :
1618 matchLabels : {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
@@ -116,21 +118,33 @@ spec:
116118 args : {{- include "common.tplvalues.render" (dict "value" .Values.master.args "context" $) | nindent 12 }}
117119 {{- else }}
118120 args :
121+ {{- if .Values.image.bitnami }}
119122 - -c
120123 - /opt/bitnami/scripts/start-scripts/start-master.sh
121- {{- end }}
124+ {{- else }}
125+ - -c
126+ - /etc/redis_scripts/start-scripts/start-master.sh
127+ {{- end -}}
128+ {{ end }}
122129 env :
130+ {{- if .Values.image.bitnami }}
123131 - name : BITNAMI_DEBUG
124132 value : {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
133+ {{- end }}
125134 - name : REDIS_REPLICATION_MODE
126135 value : master
127136 - name : ALLOW_EMPTY_PASSWORD
128137 value : {{ ternary "no" "yes" .Values.auth.enabled | quote }}
129138 {{- if .Values.auth.enabled }}
130139 {{- if .Values.auth.usePasswordFiles }}
140+ {{- if .Values.image.bitnami }}
131141 - name : REDIS_PASSWORD_FILE
132142 value : " /opt/bitnami/redis/secrets/redis-password"
133- {{- else }}
143+ {{ else }}
144+ - name : REDIS_PASSWORD_FILE
145+ value : " /etc/redis/secrets/redis-password"
146+ {{ end -}}
147+ {{ else }}
134148 - name : REDIS_PASSWORD
135149 valueFrom :
136150 secretKeyRef :
@@ -220,13 +234,23 @@ spec:
220234 resources : {{- toYaml .Values.master.resources | nindent 12 }}
221235 {{- end }}
222236 volumeMounts :
237+ {{- if .Values.image.bitnami }}
223238 - name : start-scripts
224239 mountPath : /opt/bitnami/scripts/start-scripts
240+ {{ else }}
241+ - name : redis-scripts
242+ mountPath : /etc/redis_scripts
243+ {{ end -}}
225244 - name : health
226245 mountPath : /health
227- {{- if .Values.auth.usePasswordFiles }}
246+ {{- if and .Values.auth.enabled .Values.auth.usePasswordFiles }}
247+ {{- if .Values.image.bitnami }}
228248 - name : redis-password
229249 mountPath : /opt/bitnami/redis/secrets/
250+ {{- else }}
251+ - name : redis-password
252+ mountPath : /etc/redis/secrets/
253+ {{- end }}
230254 {{- end }}
231255 - name : redis-data
232256 mountPath : {{ .Values.master.persistence.path }}
@@ -235,16 +259,29 @@ spec:
235259 {{- else if .Values.master.persistence.subPathExpr }}
236260 subPathExpr : {{ .Values.master.persistence.subPathExpr }}
237261 {{- end }}
262+ {{- if .Values.image.bitnami }}
238263 - name : config
239264 mountPath : /opt/bitnami/redis/mounted-etc
240265 - name : redis-tmp-conf
241266 mountPath : /opt/bitnami/redis/etc/
267+ {{- else }}
268+ - name : config
269+ mountPath : /etc/mounted/redis/
270+ - name : redis-tmp-conf
271+ mountPath : /etc/redis/
272+ {{- end }}
242273 - name : tmp
243274 mountPath : /tmp
244275 {{- if .Values.tls.enabled }}
276+ {{- if .Values.image.bitnami }}
245277 - name : redis-certificates
246278 mountPath : /opt/bitnami/redis/certs
247279 readOnly : true
280+ {{ else }}
281+ - name : redis-certificates
282+ mountPath : /opt/certs
283+ readOnly : true
284+ {{ end }}
248285 {{- end }}
249286 {{- if .Values.master.extraVolumeMounts }}
250287 {{- include "common.tplvalues.render" ( dict "value" .Values.master.extraVolumeMounts "context" $ ) | nindent 12 }}
@@ -263,11 +300,11 @@ spec:
263300 {{- else }}
264301 command :
265302 - /bin/bash
266- - -c
303+ - -ec
267304 - |
268- if [[ -f '/secrets/redis-password' ]]; then
269- export REDIS_PASSWORD=$(cat /secrets/redis-password)
270- fi
305+ {{- if and .Values.auth.enabled .Values.auth.usePasswordFiles }}
306+ export REDIS_PASSWORD="$(< $REDIS_PASSWORD_FILE)"
307+ {{- end }}
271308 redis_exporter{{- range $key, $value := .Values.metrics.extraArgs }} --{{ $key }}={{ $value }}{{- end }}
272309 {{- end }}
273310 {{- if .Values.diagnosticMode.enabled }}
@@ -279,7 +316,10 @@ spec:
279316 {{- if .Values.auth.enabled }}
280317 - name : REDIS_USER
281318 value : default
282- {{- if (not .Values.auth.usePasswordFiles) }}
319+ {{- if .Values.auth.usePasswordFiles }}
320+ - name : REDIS_PASSWORD_FILE
321+ value : " /secrets/redis-password"
322+ {{- else }}
283323 - name : REDIS_PASSWORD
284324 valueFrom :
285325 secretKeyRef :
@@ -333,14 +373,20 @@ spec:
333373 resources : {{- toYaml .Values.metrics.resources | nindent 12 }}
334374 {{- end }}
335375 volumeMounts :
336- {{- if .Values.auth.usePasswordFiles }}
376+ {{- if and .Values.auth.enabled .Values.auth.usePasswordFiles }}
337377 - name : redis-password
338378 mountPath : /secrets/
339379 {{- end }}
340380 {{- if .Values.tls.enabled }}
381+ {{ if .Values.image.bitnami }}
341382 - name : redis-certificates
342383 mountPath : /opt/bitnami/redis/certs
343384 readOnly : true
385+ {{ else }}
386+ - name : redis-certificates
387+ mountPath : /opt/certs
388+ readOnly : true
389+ {{ end }}
344390 {{- end }}
345391 {{- if .Values.metrics.extraVolumeMounts }}
346392 {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumeMounts "context" $ ) | nindent 12 }}
@@ -406,21 +452,70 @@ spec:
406452 {{- end }}
407453 {{- end }}
408454 volumes :
455+ {{- if .Values.image.bitnami }}
409456 - name : start-scripts
410457 configMap :
411458 name : {{ printf "%s-scripts" (include "common.names.fullname" .) }}
412459 defaultMode : 0755
460+ {{- else }}
461+ - name : redis-scripts
462+ projected :
463+ defaultMode : 0755
464+ sources :
465+ - configMap :
466+ name : {{ printf "%s-lib-redis-scripts" (include "common.names.fullname" .) }}
467+ items :
468+ - key : libfile.sh
469+ path : libfile.sh
470+ - key : libfs.sh
471+ path : libfs.sh
472+ - key : libhook.sh
473+ path : libhook.sh
474+ - key : liblog.sh
475+ path : liblog.sh
476+ - key : libnet.sh
477+ path : libnet.sh
478+ - key : libos.sh
479+ path : libos.sh
480+ - key : libredis.sh
481+ path : libredis.sh
482+ - key : libservice.sh
483+ path : libservice.sh
484+ - key : libvalidations.sh
485+ path : libvalidations.sh
486+ - key : libversion.sh
487+ path : libversion.sh
488+ - key : redis-env.sh
489+ path : redis-env.sh
490+ - key : entrypoint.sh
491+ path : redis/entrypoint.sh
492+ - key : postunpack.sh
493+ path : redis/postunpack.sh
494+ - key : run.sh
495+ path : redis/run.sh
496+ - key : setup.sh
497+ path : redis/setup.sh
498+ - configMap :
499+ name : {{ printf "%s-scripts" (include "common.names.fullname" .) }}
500+ items :
501+ - key : start-master.sh
502+ path : start-scripts/start-master.sh
503+ {{- end }}
413504 - name : health
414505 configMap :
415506 name : {{ printf "%s-health" (include "common.names.fullname" .) }}
416507 defaultMode : 0755
417- {{- if .Values.auth.usePasswordFiles }}
508+ {{- if and .Values.auth.enabled .Values.auth.usePasswordFiles }}
418509 - name : redis-password
510+ {{ if .Values.auth.usePasswordFileFromSecret }}
419511 secret :
420512 secretName : {{ template "redis.secretName" . }}
421513 items :
422514 - key : {{ template "redis.secretPasswordKey" . }}
423515 path : redis-password
516+ {{- else }}
517+ emptyDir : {}
518+ {{- end }}
424519 {{- end }}
425520 - name : config
426521 configMap :
@@ -521,3 +616,4 @@ spec:
521616 {{- include "common.storage.class" (dict "persistence" .Values.master.persistence "global" .Values.global) | nindent 8 }}
522617 {{- end }}
523618{{- end }}
619+ {{- end }}
0 commit comments