Skip to content

Commit 12b768c

Browse files
committed
chore(redis): use env replace creds volume
1 parent 088a490 commit 12b768c

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

charts/redis/templates/redis-secret-creds.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ metadata:
99
"helm.sh/hook": pre-install
1010
data:
1111
{{ if eq .Values.global.redisLocation "on-cluster"}}
12+
{{- $redisAddrs := (list ) }}
13+
{{ $redisNodeCount := .Values.replicas | int }}
14+
{{- range $i := until $redisNodeCount }}
15+
{{- $redisAddrs = (append $redisAddrs (printf "drycc-redis-%d.drycc-redis.%s.svc.%s:6379" $i $.Release.Namespace $.Values.global.clusterDomain)) }}
16+
{{- end -}}
17+
addrs: {{ join "," $redisAddrs | b64enc }}
1218
password: {{ randAlphaNum 32 | b64enc }}
1319
{{ else if eq .Values.global.redisLocation "off-cluster"}}
1420
addrs: {{ .Values.addrs | b64enc }}

charts/redis/templates/redis-statefulset.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ spec:
3939
- "6379"
4040
ports:
4141
- containerPort: 6379
42-
volumeMounts:
43-
- name: redis-creds
44-
mountPath: /var/run/secrets/drycc/redis/creds
4542
{{- if .Values.persistence.enabled }}
43+
env:
44+
- name: DRYCC_REDIS_PASSWORD
45+
valueFrom:
46+
secretKeyRef:
47+
name: redis-creds
48+
key: password
49+
volumeMounts:
4650
- name: redis-data
4751
mountPath: /data
4852
{{- end }}
4953
securityContext:
5054
fsGroup: 1001
5155
runAsGroup: 1001
5256
runAsUser: 1001
53-
volumes:
54-
- name: redis-creds
55-
secret:
56-
secretName: redis-creds
5757
{{- if .Values.persistence.enabled }}
5858
volumeClaimTemplates:
5959
- metadata:

rootfs/bin/boot

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ set -eof pipefail
55
REDIS_CONFIG_FILE=/etc/redis/redis.conf
66

77
# Set password
8-
REDIS_PASSWORD_FILE=/var/run/secrets/drycc/redis/creds/password
9-
if [ -e $REDIS_PASSWORD_FILE ]; then
10-
REDIS_PASSWORD="$(cat /var/run/secrets/drycc/redis/creds/password)"
11-
if [ -n "$REDIS_PASSWORD" ]; then
12-
printf "\nrequirepass %s" "$REDIS_PASSWORD" >> $REDIS_CONFIG_FILE
13-
fi
8+
if [ -n "$DRYCC_REDIS_PASSWORD" ]; then
9+
printf "\nrequirepass %s" "$DRYCC_REDIS_PASSWORD" >> $REDIS_CONFIG_FILE
1410
fi
1511

1612
exec redis-server $REDIS_CONFIG_FILE "$@"

0 commit comments

Comments
 (0)