Skip to content

Commit 32ce431

Browse files
fix: delete redis from bitnami and provide own templates (#1267)
* fix: remove bitnami redis and provide own templates * fix: update integration tests redis image for docker-compose * fix: update entrypoint.sh shell script with the fallback for docker * test: test new version of SC4SNMP-UI backend * chore: add changelog
1 parent da13ecd commit 32ce431

30 files changed

+621
-81
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
## Unreleased
44

55
### Changed
6+
- **Redis Migration**: Replaced Bitnami Redis chart with custom Kubernetes manifests
7+
- Updated to official Redis image version 8.2.2 (addresses security vulnerabilities)
8+
- Added authentication support (password or Kubernetes Secret)
9+
- Implemented automatic data migration from Bitnami deployments (PVC reuse)
10+
- Enabled AOF persistence by default for data durability
611
- add CounterBasedGauge64 and ZeroBasedCounter64 as metrics types
712

813
### Fixes

charts/splunk-connect-for-snmp/Chart.lock

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ dependencies:
22
- name: mongodb
33
repository: https://charts.bitnami.com/bitnami
44
version: 15.6.26
5-
- name: redis
6-
repository: https://charts.bitnami.com/bitnami
7-
version: 20.2.2
85
- name: mibserver
96
repository: https://pysnmp.github.io/mibs/charts/
107
version: 1.15.25
11-
digest: sha256:b7c83eee7395cbc67d21833ab21da52d1d43481c798e52d0a9a7f0a7c3fe05b4
12-
generated: "2025-08-13T13:56:57.099109+02:00"
8+
digest: sha256:747fcedec83bf0d80600166a021b35436d8d2ea877b60e9a43044ed2140cf1c5
9+
generated: "2025-10-13T12:15:04.255986+02:00"

charts/splunk-connect-for-snmp/Chart.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ dependencies:
2525
- name: mongodb
2626
version: ~15.6.0
2727
repository: https://charts.bitnami.com/bitnami
28-
- name: redis
29-
version: ~20.2.0
30-
repository: https://charts.bitnami.com/bitnami
3128
- name: mibserver
3229
version: ~1.15
3330
repository: https://pysnmp.github.io/mibs/charts/

charts/splunk-connect-for-snmp/templates/_helpers.tpl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,6 @@
1414
{{- end }}
1515
{{- end }}
1616

17-
{{- define "splunk-connect-for-snmp.celery_url" -}}
18-
{{- if and ( eq .Values.redis.architecture "replication" ) .Values.redis.sentinel.enabled }}
19-
{{- printf "redis://%s-redis:6379/0" .Release.Name }}
20-
{{- else }}
21-
{{- printf "redis://%s-redis-master:6379/0" .Release.Name }}
22-
{{- end }}
23-
{{- end }}
24-
25-
{{- define "splunk-connect-for-snmp.redis_url" -}}
26-
{{- if and ( eq .Values.redis.architecture "replication" ) .Values.redis.sentinel.enabled }}
27-
{{- printf "redis://%s-redis:6379/1" .Release.Name }}
28-
{{- else }}
29-
{{- printf "redis://%s-redis-master:6379/1" .Release.Name }}
30-
{{- end }}
31-
{{- end }}
32-
3317
{{/*
3418
Create a default fully qualified app name.
3519
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).

charts/splunk-connect-for-snmp/templates/inventory/job.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,28 @@ spec:
3030
env:
3131
- name: CONFIG_PATH
3232
value: /app/config/config.yaml
33-
- name: REDIS_URL
34-
value: {{ include "splunk-connect-for-snmp.redis_url" . }}
33+
{{- if .Values.redis.auth.enabled }}
34+
- name: REDIS_PASSWORD
35+
valueFrom:
36+
secretKeyRef:
37+
{{- if .Values.redis.auth.existingSecret }}
38+
name: {{ .Values.redis.auth.existingSecret }}
39+
key: {{ .Values.redis.auth.existingSecretPasswordKey | default "password" }}
40+
{{- else }}
41+
name: {{ .Release.Name }}-redis-secret
42+
key: password
43+
{{- end }}
44+
{{- end }}
45+
- name: REDIS_HOST
46+
value: {{ .Release.Name }}-redis
47+
- name: REDIS_PORT
48+
value: "6379"
49+
- name: REDIS_DB
50+
value: "1"
51+
- name: CELERY_DB
52+
value: "0"
3553
- name: INVENTORY_PATH
3654
value: /app/inventory/inventory.csv
37-
- name: CELERY_BROKER_URL
38-
value: {{ include "splunk-connect-for-snmp.celery_url" . }}
3955
- name: MONGO_URI
4056
value: {{ include "splunk-connect-for-snmp.mongo_uri" . }}
4157
- name: MIB_SOURCES
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- if eq .Values.redis.architecture "standalone" }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ .Release.Name }}-redis-config
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
app: {{ .Release.Name }}-redis
9+
data:
10+
redis.conf: |
11+
# Data directory
12+
dir /data
13+
14+
# Persistence - RDB
15+
save 900 1
16+
save 300 10
17+
save 60 10000
18+
19+
# Persistence - AOF
20+
{{- if .Values.redis.persistence.aof.enabled }}
21+
appendonly yes
22+
appendfsync {{ .Values.redis.persistence.aof.fsync }}
23+
{{- else }}
24+
appendonly no
25+
{{- end }}
26+
27+
# Logging
28+
loglevel notice
29+
30+
# Memory
31+
maxmemory-policy noeviction
32+
33+
# Network
34+
bind 0.0.0.0
35+
protected-mode no
36+
port 6379
37+
{{- end }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{- if and .Values.redis.auth.enabled (not .Values.redis.auth.existingSecret) }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ .Release.Name }}-redis-secret
6+
namespace: {{ .Release.Namespace }}
7+
type: Opaque
8+
data:
9+
password: {{ .Values.redis.auth.password | b64enc }}
10+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if eq .Values.redis.architecture "standalone" }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ .Release.Name }}-redis
6+
namespace: {{ .Release.Namespace }}
7+
spec:
8+
type: ClusterIP
9+
ports:
10+
- port: 6379
11+
targetPort: 6379
12+
name: redis
13+
selector:
14+
app: {{ .Release.Name }}-redis
15+
{{- end }}
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{{- if eq .Values.redis.architecture "standalone" }}
2+
{{- $bitnamiPVC := printf "redis-data-%s-redis-master-0" .Release.Name }}
3+
{{- $existingPVC := lookup "v1" "PersistentVolumeClaim" .Release.Namespace $bitnamiPVC }}
4+
apiVersion: apps/v1
5+
kind: StatefulSet
6+
metadata:
7+
name: {{ .Release.Name }}-redis
8+
namespace: {{ .Release.Namespace }}
9+
labels:
10+
app: {{ .Release.Name }}-redis
11+
spec:
12+
serviceName: {{ .Release.Name }}-redis
13+
replicas: 1
14+
selector:
15+
matchLabels:
16+
app: {{ .Release.Name }}-redis
17+
template:
18+
metadata:
19+
labels:
20+
app: {{ .Release.Name }}-redis
21+
annotations:
22+
checksum/config: {{ include (print $.Template.BasePath "/redis/redis-config.yaml") . | sha256sum }}
23+
spec:
24+
{{- with .Values.redis.podSecurityContext }}
25+
securityContext:
26+
runAsUser: {{ .runAsUser }}
27+
fsGroup: {{ .fsGroup }}
28+
{{- end }}
29+
initContainers:
30+
- name: fix-permissions
31+
image: {{ .Values.redis.image.repository }}:{{ .Values.redis.image.tag }}
32+
imagePullPolicy: {{ .Values.redis.image.pullPolicy }}
33+
command:
34+
- sh
35+
- -c
36+
- |
37+
echo "=== Redis Init: Fixing Permissions ==="
38+
echo "Current ownership:"
39+
ls -ln /data
40+
echo ""
41+
echo "Fixing ownership to {{ .Values.redis.podSecurityContext.runAsUser }}:{{ .Values.redis.podSecurityContext.fsGroup }}..."
42+
chown -R {{ .Values.redis.podSecurityContext.runAsUser }}:{{ .Values.redis.podSecurityContext.fsGroup }} /data
43+
chmod -R 755 /data
44+
echo ""
45+
echo "New ownership:"
46+
ls -ln /data
47+
echo "=== Permissions Fixed ==="
48+
volumeMounts:
49+
- name: redis-data
50+
mountPath: /data
51+
securityContext:
52+
runAsUser: 0 # Must run as root to chown
53+
containers:
54+
- name: redis
55+
image: {{ .Values.redis.image.repository }}:{{ .Values.redis.image.tag }}
56+
imagePullPolicy: {{ .Values.redis.image.pullPolicy }}
57+
ports:
58+
- containerPort: 6379
59+
name: redis
60+
command:
61+
- sh
62+
- -c
63+
args:
64+
- |
65+
# Copy config to writable location
66+
cp /etc/redis/redis.conf /tmp/redis.conf
67+
68+
{{- if .Values.redis.auth.enabled }}
69+
# Append password at runtime
70+
echo "requirepass $REDIS_PASSWORD" >> /tmp/redis.conf
71+
{{- end }}
72+
73+
# Start Redis
74+
exec redis-server /tmp/redis.conf
75+
{{- if .Values.redis.auth.enabled }}
76+
env:
77+
- name: REDIS_PASSWORD
78+
valueFrom:
79+
secretKeyRef:
80+
{{- if .Values.redis.auth.existingSecret }}
81+
name: {{ .Values.redis.auth.existingSecret }}
82+
key: {{ .Values.redis.auth.existingSecretPasswordKey | default "password" }}
83+
{{- else }}
84+
name: {{ .Release.Name }}-redis-secret
85+
key: password
86+
{{- end }}
87+
{{- end }}
88+
volumeMounts:
89+
- name: redis-data
90+
mountPath: /data
91+
- name: redis-config
92+
mountPath: /etc/redis
93+
resources:
94+
{{- toYaml .Values.redis.resources | nindent 10 }}
95+
livenessProbe:
96+
exec:
97+
command:
98+
- sh
99+
- -c
100+
- |
101+
{{- if .Values.redis.auth.enabled }}
102+
redis-cli -a "$REDIS_PASSWORD" ping
103+
{{- else }}
104+
redis-cli ping
105+
{{- end }}
106+
initialDelaySeconds: 30
107+
periodSeconds: 10
108+
readinessProbe:
109+
exec:
110+
command:
111+
- sh
112+
- -c
113+
- |
114+
{{- if .Values.redis.auth.enabled }}
115+
redis-cli -a "$REDIS_PASSWORD" ping
116+
{{- else }}
117+
redis-cli ping
118+
{{- end }}
119+
initialDelaySeconds: 5
120+
periodSeconds: 5
121+
{{- if and .Values.redis.storage.enabled $existingPVC }}
122+
# Reuse existing Bitnami PVC
123+
volumes:
124+
- name: redis-data
125+
persistentVolumeClaim:
126+
claimName: {{ $bitnamiPVC }}
127+
- name: redis-config
128+
configMap:
129+
name: {{ .Release.Name }}-redis-config
130+
{{- else if .Values.redis.storage.enabled }}
131+
# Storage enabled but no existing PVC - use volumeClaimTemplates below
132+
volumes:
133+
- name: redis-config
134+
configMap:
135+
name: {{ .Release.Name }}-redis-config
136+
{{- else }}
137+
# Storage disabled - use emptyDir (ephemeral)
138+
volumes:
139+
- name: redis-data
140+
emptyDir: {}
141+
- name: redis-config
142+
configMap:
143+
name: {{ .Release.Name }}-redis-config
144+
{{- end }}
145+
{{- if and .Values.redis.storage.enabled (not $existingPVC) }}
146+
# No existing PVC found, create new one via volumeClaimTemplates
147+
volumeClaimTemplates:
148+
- metadata:
149+
name: redis-data
150+
spec:
151+
accessModes: {{ toYaml .Values.redis.storage.accessModes | nindent 8 }}
152+
{{- if .Values.redis.storage.storageClassName }}
153+
storageClassName: {{ .Values.redis.storage.storageClassName }}
154+
{{- end }}
155+
resources:
156+
requests:
157+
storage: {{ .Values.redis.storage.size }}
158+
{{- end }}
159+
{{- end }}

charts/splunk-connect-for-snmp/templates/scheduler/deployment.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,26 @@ spec:
4545
env:
4646
- name: CONFIG_PATH
4747
value: /app/config/config.yaml
48-
- name: REDIS_URL
49-
value: {{ include "splunk-connect-for-snmp.redis_url" . }}
50-
- name: CELERY_BROKER_URL
51-
value: {{ include "splunk-connect-for-snmp.celery_url" . }}
48+
{{- if .Values.redis.auth.enabled }}
49+
- name: REDIS_PASSWORD
50+
valueFrom:
51+
secretKeyRef:
52+
{{- if .Values.redis.auth.existingSecret }}
53+
name: {{ .Values.redis.auth.existingSecret }}
54+
key: {{ .Values.redis.auth.existingSecretPasswordKey | default "password" }}
55+
{{- else }}
56+
name: {{ .Release.Name }}-redis-secret
57+
key: password
58+
{{- end }}
59+
{{- end }}
60+
- name: REDIS_HOST
61+
value: {{ .Release.Name }}-redis
62+
- name: REDIS_PORT
63+
value: "6379"
64+
- name: REDIS_DB
65+
value: "1"
66+
- name: CELERY_DB
67+
value: "0"
5268
- name: MONGO_URI
5369
value: {{ include "splunk-connect-for-snmp.mongo_uri" . }}
5470
- name: MIB_SOURCES

0 commit comments

Comments
 (0)