Skip to content

Commit 59230c9

Browse files
redis chart modified (#5)
* modified tests for 01|02.golden.yaml * added non-bitnami version for 01.golden.yaml , 02.golden.yaml values files
1 parent 3406cd6 commit 59230c9

42 files changed

Lines changed: 8801 additions & 760 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

charts/redis/templates/_helpers.tpl

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,32 +89,56 @@ Return the secret containing Redis TLS certificates
8989
Return the path to the cert file.
9090
*/}}
9191
{{- define "redis.tlsCert" -}}
92-
{{- if (include "redis.createTlsSecret" . ) -}}
93-
{{- printf "/opt/bitnami/redis/certs/%s" "tls.crt" -}}
92+
{{- if .Values.image.bitnami -}}
93+
{{- if (include "redis.createTlsSecret" . ) -}}
94+
{{- printf "/opt/bitnami/redis/certs/%s" "tls.crt" -}}
95+
{{- else -}}
96+
{{- required "Certificate filename is required when TLS in enabled" .Values.tls.certFilename | printf "/opt/bitnami/redis/certs/%s" -}}
97+
{{- end -}}
9498
{{- else -}}
95-
{{- required "Certificate filename is required when TLS in enabled" .Values.tls.certFilename | printf "/opt/bitnami/redis/certs/%s" -}}
99+
{{- if (include "redis.createTlsSecret" . ) -}}
100+
{{- printf "/opt/certs/%s" "tls.crt" -}}
101+
{{- else -}}
102+
{{- required "Certificate filename is required when TLS in enabled" .Values.tls.certFilename | printf "/opt/certs/%s" -}}
103+
{{- end -}}
96104
{{- end -}}
97105
{{- end -}}
98106

99107
{{/*
100108
Return the path to the cert key file.
101109
*/}}
102110
{{- define "redis.tlsCertKey" -}}
103-
{{- if (include "redis.createTlsSecret" . ) -}}
104-
{{- printf "/opt/bitnami/redis/certs/%s" "tls.key" -}}
111+
{{- if .Values.image.bitnami -}}
112+
{{- if (include "redis.createTlsSecret" . ) -}}
113+
{{- printf "/opt/bitnami/redis/certs/%s" "tls.key" -}}
114+
{{- else -}}
115+
{{- required "Certificate Key filename is required when TLS in enabled" .Values.tls.certKeyFilename | printf "/opt/bitnami/redis/certs/%s" -}}
116+
{{- end -}}
105117
{{- else -}}
106-
{{- required "Certificate Key filename is required when TLS in enabled" .Values.tls.certKeyFilename | printf "/opt/bitnami/redis/certs/%s" -}}
118+
{{- if (include "redis.createTlsSecret" . ) -}}
119+
{{- printf "/opt/certs/%s" "tls.key" -}}
120+
{{- else -}}
121+
{{- required "Certificate Key filename is required when TLS in enabled" .Values.tls.certKeyFilename | printf "/opt/certs/%s" -}}
122+
{{- end -}}
107123
{{- end -}}
108124
{{- end -}}
109125

110126
{{/*
111127
Return the path to the CA cert file.
112128
*/}}
113129
{{- define "redis.tlsCACert" -}}
114-
{{- if (include "redis.createTlsSecret" . ) -}}
115-
{{- printf "/opt/bitnami/redis/certs/%s" "ca.crt" -}}
130+
{{- if .Values.image.bitnami -}}
131+
{{- if (include "redis.createTlsSecret" . ) -}}
132+
{{- printf "/opt/bitnami/redis/certs/%s" "ca.crt" -}}
133+
{{- else -}}
134+
{{- required "Certificate CA filename is required when TLS in enabled" .Values.tls.certCAFilename | printf "/opt/bitnami/redis/certs/%s" -}}
135+
{{- end -}}
116136
{{- else -}}
117-
{{- required "Certificate CA filename is required when TLS in enabled" .Values.tls.certCAFilename | printf "/opt/bitnami/redis/certs/%s" -}}
137+
{{- if (include "redis.createTlsSecret" . ) -}}
138+
{{- printf "/opt/certs/%s" "ca.crt" -}}
139+
{{- else -}}
140+
{{- required "Certificate CA filename is required when TLS in enabled" .Values.tls.certCAFilename | printf "/opt/certs/%s" -}}
141+
{{- end -}}
118142
{{- end -}}
119143
{{- end -}}
120144

@@ -123,7 +147,11 @@ Return the path to the DH params file.
123147
*/}}
124148
{{- define "redis.tlsDHParams" -}}
125149
{{- if .Values.tls.dhParamsFilename -}}
126-
{{- printf "/opt/bitnami/redis/certs/%s" .Values.tls.dhParamsFilename -}}
150+
{{- if .Values.image.bitnami -}}
151+
{{- printf "/opt/bitnami/redis/certs/%s" .Values.tls.dhParamsFilename -}}
152+
{{- else -}}
153+
{{- printf "/opt/certs/%s" .Values.tls.dhParamsFilename -}}
154+
{{- end -}}
127155
{{- end -}}
128156
{{- end -}}
129157

charts/redis/templates/configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: v1
33
kind: ConfigMap
44
metadata:
55
name: {{ printf "%s-configuration" (include "common.names.fullname" .) }}
6-
namespace: {{ .Release.Namespace | quote }}
6+
namespace: {{ include "common.names.namespace" . | quote }}
77
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
88
{{- if .Values.commonAnnotations }}
99
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}

charts/redis/templates/headless-svc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: {{ printf "%s-headless" (include "common.names.fullname" .) }}
5-
namespace: {{ .Release.Namespace | quote }}
5+
namespace: {{ include "common.names.namespace" . | quote }}
66
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
77
annotations:
88
{{- if or .Values.sentinel.service.headless.annotations .Values.commonAnnotations }}

charts/redis/templates/health-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: ConfigMap
33
metadata:
44
name: {{ printf "%s-health" (include "common.names.fullname" .) }}
5-
namespace: {{ .Release.Namespace | quote }}
5+
namespace: {{ include "common.names.namespace" . | quote }}
66
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
77
{{- if .Values.commonAnnotations }}
88
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}

charts/redis/templates/master/application.yaml

Lines changed: 108 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
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) }}
23
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
34
kind: {{ .Values.master.kind }}
45
metadata:
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 }}
1213
spec:
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 }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- $pdb := coalesce .Values.pdb .Values.master.pdb }}
2+
{{- if and $pdb.create (gt (int64 .Values.master.count) 0) (or (ne .Values.architecture "replication") (not .Values.sentinel.enabled)) }}
3+
apiVersion: {{ include "common.capabilities.policy.apiVersion" . }}
4+
kind: PodDisruptionBudget
5+
metadata:
6+
name: {{ printf "%s-master" (include "common.names.fullname" .) }}
7+
namespace: {{ include "common.names.namespace" . | quote }}
8+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
9+
app.kubernetes.io/component: master
10+
{{- if .Values.commonAnnotations }}
11+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
12+
{{- end }}
13+
spec:
14+
{{- if $pdb.minAvailable }}
15+
minAvailable: {{ $pdb.minAvailable }}
16+
{{- else }}
17+
maxUnavailable: {{ $pdb.maxUnavailable | default 1 }}
18+
{{- end }}
19+
selector:
20+
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 6 }}
21+
app.kubernetes.io/component: master
22+
{{- end }}

charts/redis/templates/master/psp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: policy/v1beta1
33
kind: PodSecurityPolicy
44
metadata:
55
name: {{ printf "%s-master" (include "common.names.fullname" .) }}
6-
namespace: {{ .Release.Namespace | quote }}
6+
namespace: {{ include "common.names.namespace" . | quote }}
77
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
88
{{- if .Values.commonAnnotations }}
99
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}

charts/redis/templates/master/pvc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: PersistentVolumeClaim
33
apiVersion: v1
44
metadata:
55
name: {{ printf "redis-data-%s-master" (include "common.names.fullname" .) }}
6-
namespace: {{ .Release.Namespace | quote }}
6+
namespace: {{ include "common.names.namespace" . | quote }}
77
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.master.persistence.labels .Values.commonLabels ) "context" . ) }}
88
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
99
app.kubernetes.io/component: master

charts/redis/templates/master/service.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
{{- if not .Values.sentinel.enabled }}
1+
{{- if and (not .Values.sentinel.enabled) (gt (int64 .Values.master.count) 0) }}
22
apiVersion: v1
33
kind: Service
44
metadata:
55
name: {{ printf "%s-master" (include "common.names.fullname" .) }}
6-
namespace: {{ .Release.Namespace | quote }}
6+
namespace: {{ include "common.names.namespace" . | quote }}
77
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
88
app.kubernetes.io/component: master
99
{{- if or .Values.master.service.annotations .Values.commonAnnotations }}

0 commit comments

Comments
 (0)