-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathinit_config.yaml
More file actions
74 lines (63 loc) · 1.91 KB
/
Copy pathinit_config.yaml
File metadata and controls
74 lines (63 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "valkey.fullname" . }}-init-scripts
labels:
{{- include "valkey.labels" . | nindent 4 }}
data:
init.sh: |-
#!/bin/bash
set -euo pipefail
# Default config paths
VALKEY_CONFIG=${VALKEY_CONFIG_PATH:-/data/conf/valkey.conf}
LOGFILE="/data/init.log"
DATA_DIR="/data/conf"
# Logging function
log() {
echo "$(date) $1" | tee -a "$LOGFILE"
}
# Clean old log if requested
if [ "${KEEP_OLD_LOGS:-false}" != "true" ]; then
rm -f "$LOGFILE"
fi
if [ -f "$LOGFILE" ]; then
log "Detected restart of this instance ($HOSTNAME)"
fi
log "Creating configuration in $DATA_DIR..."
mkdir -p "$DATA_DIR"
rm -f "$VALKEY_CONFIG"
# Base valkey.conf
log "Generating base valkey.conf"
{
echo "port 6379"
echo "protected-mode no"
echo "bind 0.0.0.0"
echo "dir /data"
} >>"$VALKEY_CONFIG"
{{- if .Values.auth.enabled }}
echo "aclfile /data/conf/users.acl" >>"$VALKEY_CONFIG"
{{- if or .Values.auth.generateDefaultUser.enabled .Values.auth.existingSecret }}
# Copy ACL from mounted secret
if [ -f /valkey-auth/users.acl ]; then
log "Using ACL configuration from secret"
cp /valkey-auth/users.acl /data/conf/users.acl
else
log "ERROR: auth.enabled is true but no ACL file found in secret"
exit 1
fi
{{- else }}
# Use inline ACL configuration
cat <<EOF > /data/conf/users.acl
{{ .Values.auth.aclConfig | indent 6 }}
EOF
{{- end }}
{{- end }}
# Append extra configs if present
if [ -f /usr/local/etc/valkey/valkey.conf ]; then
log "Appending /usr/local/etc/valkey/valkey.conf"
cat /usr/local/etc/valkey/valkey.conf >>"$VALKEY_CONFIG"
fi
if [ -d /extravalkeyconfigs ]; then
log "Appending files in /extravalkeyconfigs/"
cat /extravalkeyconfigs/* >>"$VALKEY_CONFIG"
fi