Skip to content

Commit bbe42e4

Browse files
committed
feat: update diode chart to support external redis username
1 parent 68571b3 commit bbe42e4

File tree

8 files changed

+24
-0
lines changed

8 files changed

+24
-0
lines changed

charts/diode/templates/_helpers.tpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,19 @@ Create the port of the Redis database
291291
{{- end }}
292292
{{- end }}
293293

294+
{{/*
295+
Create the username of the Redis database
296+
*/}}
297+
{{- define "diode.redis.username" -}}
298+
{{- if .Values.redis.enabled -}}
299+
{{- printf "" }}
300+
{{- else if and .Values.externalRedis (hasKey .Values.externalRedis "username") -}}
301+
{{- .Values.externalRedis.username }}
302+
{{- else -}}
303+
{{- fail "externalRedis.username must be defined when redis.enabled is false" }}
304+
{{- end }}
305+
{{- end }}
306+
294307
{{/*
295308
Create the database name for PostgreSQL
296309
*/}}

charts/diode/templates/diode-ingester-configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ data:
1717
SENTRY_DSN: {{ $config.sentryDsn | quote }}
1818
REDIS_HOST: {{ include "diode.redis.hostname" . | quote }}
1919
REDIS_PORT: {{ include "diode.redis.port" . | quote }}
20+
REDIS_USERNAME: {{ include "diode.redis.username" . | quote }}
2021
{{- if and .Values.externalRedis.tls .Values.externalRedis.tls.enabled }}
2122
REDIS_TLS_ENABLED: "true"
2223
REDIS_TLS_SKIP_VERIFY: {{ .Values.externalRedis.tls.skipVerify | default false | quote }}

charts/diode/templates/diode-reconciler-configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ data:
1717
SENTRY_DSN: {{ $config.sentryDsn | quote }}
1818
REDIS_HOST: {{ include "diode.redis.hostname" . | quote }}
1919
REDIS_PORT: {{ include "diode.redis.port" . | quote }}
20+
REDIS_USERNAME: {{ include "diode.redis.username" . | quote }}
2021
REDIS_DB: {{ $config.redisDb | default "0" | quote }}
2122
REDIS_STREAM_DB: {{ $config.redisStreamDb | default "1" | quote }}
2223
{{- if and .Values.externalRedis.tls .Values.externalRedis.tls.enabled }}

charts/diode/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ externalRedis:
5757
hostname: localhost
5858
# -- port
5959
port: 6379
60+
# -- username (optional, Redis 6+)
61+
username: ""
6062
tls:
6163
# -- enable TLS
6264
enabled: false

diode-server/docker/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ services:
2323
- REDIS_PASSWORD=${REDIS_PASSWORD}
2424
- REDIS_HOST=${REDIS_HOST}
2525
- REDIS_PORT=${REDIS_PORT}
26+
- REDIS_USERNAME=""
2627
- SENTRY_DSN=${SENTRY_DSN}
2728
- TELEMETRY_METRICS_EXPORTER=${TELEMETRY_METRICS_EXPORTER}
2829
- TELEMETRY_TRACES_EXPORTER=${TELEMETRY_TRACES_EXPORTER}
@@ -40,6 +41,7 @@ services:
4041
- REDIS_PASSWORD=${REDIS_PASSWORD}
4142
- REDIS_HOST=${REDIS_HOST}
4243
- REDIS_PORT=${REDIS_PORT}
44+
- REDIS_USERNAME=""
4345
- NETBOX_DIODE_PLUGIN_API_BASE_URL=${NETBOX_DIODE_PLUGIN_API_BASE_URL}
4446
- NETBOX_DIODE_PLUGIN_SKIP_TLS_VERIFY=${NETBOX_DIODE_PLUGIN_SKIP_TLS_VERIFY}
4547
- LOGGING_LEVEL=${LOGGING_LEVEL}

diode-server/docker/sample.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ DIODE_NGINX_PORT=8080
22
REDIS_PASSWORD=<PLACEHOLDER_SECRET>
33
REDIS_HOST=redis
44
REDIS_PORT=6378
5+
REDIS_USERNAME=""
56
NETBOX_DIODE_PLUGIN_API_BASE_URL=<http://NETBOX_HOST>/api/plugins/diode
67
NETBOX_DIODE_PLUGIN_SKIP_TLS_VERIFY=false
78
LOGGING_LEVEL=DEBUG

diode-server/ingester/component_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func setupEnv(redisAddr string) {
4545
_ = os.Setenv("GRPC_PORT", grpcPort)
4646
_ = os.Setenv("REDIS_HOST", host)
4747
_ = os.Setenv("REDIS_PORT", port)
48+
_ = os.Setenv("REDIS_USERNAME", "")
4849
_ = os.Setenv("REDIS_PASSWORD", "")
4950
_ = os.Setenv("REDIS_DB", "0")
5051
_ = os.Setenv("REDIS_STREAM_DB", "1")
@@ -59,6 +60,7 @@ func teardownEnv() {
5960
_ = os.Unsetenv("GRPC_PORT")
6061
_ = os.Unsetenv("REDIS_HOST")
6162
_ = os.Unsetenv("REDIS_PORT")
63+
_ = os.Unsetenv("REDIS_USERNAME")
6264
_ = os.Unsetenv("REDIS_PASSWORD")
6365
_ = os.Unsetenv("REDIS_DB")
6466
_ = os.Unsetenv("REDIS_STREAM_DB")

diode-server/reconciler/reconciler_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func setupEnv(redisAddr string) {
2626
_ = os.Setenv("GRPC_PORT", grpcPort)
2727
_ = os.Setenv("REDIS_HOST", host)
2828
_ = os.Setenv("REDIS_PORT", port)
29+
_ = os.Setenv("REDIS_USERNAME", "")
2930
_ = os.Setenv("REDIS_PASSWORD", "")
3031
_ = os.Setenv("REDIS_DB", "0")
3132
_ = os.Setenv("REDIS_STREAM_DB", "1")
@@ -49,6 +50,7 @@ func teardownEnv() {
4950
_ = os.Unsetenv("GRPC_PORT")
5051
_ = os.Unsetenv("REDIS_HOST")
5152
_ = os.Unsetenv("REDIS_PORT")
53+
_ = os.Unsetenv("REDIS_USERNAME")
5254
_ = os.Unsetenv("REDIS_PASSWORD")
5355
_ = os.Unsetenv("REDIS_DB")
5456
_ = os.Unsetenv("REDIS_STREAM_DB")

0 commit comments

Comments
 (0)