Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/diode/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: diode
description: A Helm chart for Diode
type: application
version: "1.9.1"
version: "1.10.0"
appVersion: "1.5.0"
home: https://github.com/netboxlabs/diode
sources:
Expand Down
11 changes: 6 additions & 5 deletions charts/diode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Helm chart for Diode

![Version: 1.9.1](https://img.shields.io/badge/Version-1.9.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.5.0](https://img.shields.io/badge/AppVersion-1.5.0-informational?style=flat-square)
![Version: 1.10.0](https://img.shields.io/badge/Version-1.10.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.5.0](https://img.shields.io/badge/AppVersion-1.5.0-informational?style=flat-square)

## Prerequisites

Expand Down Expand Up @@ -240,15 +240,15 @@ helm show values diode/diode
| diodeAuth.image.imagePullSecrets | list | `[]` | secrets with credentials to pull images from a private registry |
| diodeAuth.image.pullPolicy | string | `"IfNotPresent"` | pull policy |
| diodeAuth.image.repository | string | `"docker.io/netboxlabs/diode-auth"` | image repository |
| diodeAuth.image.tag | string | `"1.8.0"` | image tag |
| diodeAuth.image.tag | string | `"1.10.0"` | image tag |
| diodeAuth.replicaCount | int | `1` | replica count |
| diodeAuth.resources | object | `{"limits":{"cpu":"500m","memory":"512Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}` | resources |
| diodeAuth.serviceAccount.create | bool | `true` | create service account |
| diodeAuthBootstrap.enabled | bool | `true` | enabled |
| diodeAuthBootstrap.image.imagePullSecrets | list | `[]` | secrets with credentials to pull images from a private registry |
| diodeAuthBootstrap.image.pullPolicy | string | `"IfNotPresent"` | pull policy |
| diodeAuthBootstrap.image.repository | string | `"docker.io/netboxlabs/diode-auth"` | image repository |
| diodeAuthBootstrap.image.tag | string | `"1.8.0"` | image tag |
| diodeAuthBootstrap.image.tag | string | `"1.10.0"` | image tag |
| diodeAuthBootstrap.job.annotations | object | `{"helm.sh/hook":"post-install, post-upgrade","helm.sh/hook-weight":"2"}` | annotations to add to the auth bootstrap job |
| diodeAuthBootstrap.job.backoffLimit | int | `20` | backoff limit |
| diodeAuthBootstrap.job.extraInitContainers | string or list | `""` | additional initContainers to run during bootstrap (may contain templating instructions) |
Expand All @@ -268,7 +268,7 @@ helm show values diode/diode
| diodeIngester.image.imagePullSecrets | list | `[]` | secrets with credentials to pull images from a private registry |
| diodeIngester.image.pullPolicy | string | `"IfNotPresent"` | pull policy |
| diodeIngester.image.repository | string | `"docker.io/netboxlabs/diode-ingester"` | image repository |
| diodeIngester.image.tag | string | `"1.9.0"` | image tag |
| diodeIngester.image.tag | string | `"1.11.0"` | image tag |
| diodeIngester.replicaCount | int | `1` | replica count |
| diodeIngester.resources | object | `{"limits":{"cpu":"500m","memory":"512Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}` | resources |
| diodeIngester.serviceAccount.create | bool | `true` | create service account |
Expand Down Expand Up @@ -300,7 +300,7 @@ helm show values diode/diode
| diodeReconciler.image.imagePullSecrets | list | `[]` | secrets with credentials to pull images from a private registry |
| diodeReconciler.image.pullPolicy | string | `"IfNotPresent"` | pull policy |
| diodeReconciler.image.repository | string | `"docker.io/netboxlabs/diode-reconciler"` | image repository |
| diodeReconciler.image.tag | string | `"1.9.0"` | image tag |
| diodeReconciler.image.tag | string | `"1.11.0"` | image tag |
| diodeReconciler.replicaCount | int | `1` | replica count |
| diodeReconciler.resources | object | `{"limits":{"cpu":"500m","memory":"512Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}` | resources |
| diodeReconciler.serviceAccount.create | bool | `true` | create service account |
Expand All @@ -319,6 +319,7 @@ helm show values diode/diode
| externalRedis.tls.clientKeyPath | string | `""` | path to client private key for mutual TLS |
| externalRedis.tls.enabled | bool | `false` | enable TLS |
| externalRedis.tls.skipVerify | bool | `false` | skip TLS verify |
| externalRedis.username | string | `""` | username (optional, Redis 6+) |
| global.commonAnnotations | object | `{}` | common annotations for all resources |
| global.commonLabels | object | `{}` | common labels for all resources |
| global.diode | object | `{"busybox":{"image":"busybox:latest","imagePullPolicy":"IfNotPresent"},"hydra":{"waitForPostgres":true},"ingester":{"waitForRedis":true},"reconciler":{"waitForPostgres":true,"waitForRedis":true}}` | diode global configuration |
Expand Down
13 changes: 13 additions & 0 deletions charts/diode/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ Create the port of the Redis database
{{- end }}
{{- end }}

{{/*
Create the username of the Redis database
*/}}
{{- define "diode.redis.username" -}}
{{- if .Values.redis.enabled -}}
{{- printf "" }}
{{- else if and .Values.externalRedis (hasKey .Values.externalRedis "username") -}}
{{- .Values.externalRedis.username }}
{{- else -}}
{{- fail "externalRedis.username must be defined when redis.enabled is false" }}
{{- end }}
{{- end }}

{{/*
Create the database name for PostgreSQL
*/}}
Expand Down
1 change: 1 addition & 0 deletions charts/diode/templates/diode-ingester-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data:
SENTRY_DSN: {{ $config.sentryDsn | quote }}
REDIS_HOST: {{ include "diode.redis.hostname" . | quote }}
REDIS_PORT: {{ include "diode.redis.port" . | quote }}
REDIS_USERNAME: {{ include "diode.redis.username" . | quote }}
{{- if and .Values.externalRedis.tls .Values.externalRedis.tls.enabled }}
REDIS_TLS_ENABLED: "true"
REDIS_TLS_SKIP_VERIFY: {{ .Values.externalRedis.tls.skipVerify | default false | quote }}
Expand Down
1 change: 1 addition & 0 deletions charts/diode/templates/diode-reconciler-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data:
SENTRY_DSN: {{ $config.sentryDsn | quote }}
REDIS_HOST: {{ include "diode.redis.hostname" . | quote }}
REDIS_PORT: {{ include "diode.redis.port" . | quote }}
REDIS_USERNAME: {{ include "diode.redis.username" . | quote }}
REDIS_DB: {{ $config.redisDb | default "0" | quote }}
REDIS_STREAM_DB: {{ $config.redisStreamDb | default "1" | quote }}
{{- if and .Values.externalRedis.tls .Values.externalRedis.tls.enabled }}
Expand Down
10 changes: 6 additions & 4 deletions charts/diode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ externalRedis:
hostname: localhost
# -- port
port: 6379
# -- username (optional, Redis 6+)
username: ""
tls:
# -- enable TLS
enabled: false
Expand All @@ -77,7 +79,7 @@ diodeAuth:
# -- image repository
repository: docker.io/netboxlabs/diode-auth
# -- image tag
tag: 1.8.0
tag: 1.10.0
# -- secrets with credentials to pull images from a private registry
imagePullSecrets: []
# -- pull policy
Expand Down Expand Up @@ -123,7 +125,7 @@ diodeAuthBootstrap:
# -- image repository
repository: docker.io/netboxlabs/diode-auth
# -- image tag
tag: 1.8.0
tag: 1.10.0
# -- secrets with credentials to pull images from a private registry
imagePullSecrets: []
# -- pull policy
Expand All @@ -146,7 +148,7 @@ diodeIngester:
# -- image repository
repository: docker.io/netboxlabs/diode-ingester
# -- image tag
tag: 1.9.0
tag: 1.11.0
# -- secrets with credentials to pull images from a private registry
imagePullSecrets: []
# -- pull policy
Expand Down Expand Up @@ -199,7 +201,7 @@ diodeReconciler:
# -- image repository
repository: docker.io/netboxlabs/diode-reconciler
# -- image tag
tag: 1.9.0
tag: 1.11.0
# -- secrets with credentials to pull images from a private registry
imagePullSecrets: []
# -- pull policy
Expand Down
8 changes: 6 additions & 2 deletions diode-server/cmd/ingester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ func main() {
os.Exit(1)
}

redisStreamClient := redis.NewClient(&redis.Options{
redisOptions := redis.Options{
Addr: fmt.Sprintf("%s:%s", cfg.RedisHost, cfg.RedisPort),
Password: cfg.RedisPassword,
DB: cfg.RedisStreamDB,
TLSConfig: redisTLSConfig,
})
}
if cfg.RedisUsername != "" {
redisOptions.Username = cfg.RedisUsername
}
redisStreamClient := redis.NewClient(&redisOptions)

if _, err := redisStreamClient.Ping(ctx).Result(); err != nil {
s.Logger().Error("failed to connect to redis stream", "redisStream", redisStreamClient.String(), "error", err)
Expand Down
16 changes: 12 additions & 4 deletions diode-server/cmd/reconciler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,33 @@ func main() {
os.Exit(1)
}

redisClient := redis.NewClient(&redis.Options{
redisOptions := redis.Options{
Addr: fmt.Sprintf("%s:%s", cfg.RedisHost, cfg.RedisPort),
Password: cfg.RedisPassword,
DB: cfg.RedisDB,
TLSConfig: redisTLSConfig,
})
}
if cfg.RedisUsername != "" {
redisOptions.Username = cfg.RedisUsername
}
redisClient := redis.NewClient(&redisOptions)

if _, err := redisClient.Ping(ctx).Result(); err != nil {
s.Logger().Error("failed to connect to redis", "redis", redisClient.String(), "error", err)
metricRecorder.RecordServiceStartupAttempt(ctx, false)
os.Exit(1)
}

redisStreamClient := redis.NewClient(&redis.Options{
redisStreamOptions := redis.Options{
Addr: fmt.Sprintf("%s:%s", cfg.RedisHost, cfg.RedisPort),
Password: cfg.RedisPassword,
DB: cfg.RedisStreamDB,
TLSConfig: redisTLSConfig,
})
}
if cfg.RedisUsername != "" {
redisStreamOptions.Username = cfg.RedisUsername
}
redisStreamClient := redis.NewClient(&redisStreamOptions)

if _, err := redisStreamClient.Ping(ctx).Result(); err != nil {
s.Logger().Error("failed to connect to redis stream", "redisStream", redisStreamClient.String(), "error", err)
Expand Down
2 changes: 2 additions & 0 deletions diode-server/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_HOST=${REDIS_HOST}
- REDIS_PORT=${REDIS_PORT}
- REDIS_USERNAME=""
- SENTRY_DSN=${SENTRY_DSN}
- TELEMETRY_METRICS_EXPORTER=${TELEMETRY_METRICS_EXPORTER}
- TELEMETRY_TRACES_EXPORTER=${TELEMETRY_TRACES_EXPORTER}
Expand All @@ -40,6 +41,7 @@ services:
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_HOST=${REDIS_HOST}
- REDIS_PORT=${REDIS_PORT}
- REDIS_USERNAME=""
- NETBOX_DIODE_PLUGIN_API_BASE_URL=${NETBOX_DIODE_PLUGIN_API_BASE_URL}
- NETBOX_DIODE_PLUGIN_SKIP_TLS_VERIFY=${NETBOX_DIODE_PLUGIN_SKIP_TLS_VERIFY}
- LOGGING_LEVEL=${LOGGING_LEVEL}
Expand Down
1 change: 1 addition & 0 deletions diode-server/docker/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ DIODE_NGINX_PORT=8080
REDIS_PASSWORD=<PLACEHOLDER_SECRET>
REDIS_HOST=redis
REDIS_PORT=6378
REDIS_USERNAME=""
NETBOX_DIODE_PLUGIN_API_BASE_URL=<http://NETBOX_HOST>/api/plugins/diode
NETBOX_DIODE_PLUGIN_SKIP_TLS_VERIFY=false
LOGGING_LEVEL=DEBUG
Expand Down
2 changes: 2 additions & 0 deletions diode-server/ingester/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func setupEnv(redisAddr string) {
_ = os.Setenv("GRPC_PORT", grpcPort)
_ = os.Setenv("REDIS_HOST", host)
_ = os.Setenv("REDIS_PORT", port)
_ = os.Setenv("REDIS_USERNAME", "")
_ = os.Setenv("REDIS_PASSWORD", "")
_ = os.Setenv("REDIS_DB", "0")
_ = os.Setenv("REDIS_STREAM_DB", "1")
Expand All @@ -59,6 +60,7 @@ func teardownEnv() {
_ = os.Unsetenv("GRPC_PORT")
_ = os.Unsetenv("REDIS_HOST")
_ = os.Unsetenv("REDIS_PORT")
_ = os.Unsetenv("REDIS_USERNAME")
_ = os.Unsetenv("REDIS_PASSWORD")
_ = os.Unsetenv("REDIS_DB")
_ = os.Unsetenv("REDIS_STREAM_DB")
Expand Down
1 change: 1 addition & 0 deletions diode-server/ingester/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Config struct {
GRPCPort int `envconfig:"GRPC_PORT" default:"8081"`
RedisHost string `envconfig:"REDIS_HOST" default:"127.0.0.1"`
RedisPort string `envconfig:"REDIS_PORT" default:"6379"`
RedisUsername string `envconfig:"REDIS_USERNAME" default:""`
RedisPassword string `envconfig:"REDIS_PASSWORD" required:"true"`
RedisStreamDB int `envconfig:"REDIS_STREAM_DB" default:"1"`

Expand Down
1 change: 1 addition & 0 deletions diode-server/reconciler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Config struct {
GRPCPort int `envconfig:"GRPC_PORT" default:"8081"`
RedisHost string `envconfig:"REDIS_HOST" default:"127.0.0.1"`
RedisPort string `envconfig:"REDIS_PORT" default:"6379"`
RedisUsername string `envconfig:"REDIS_USERNAME" default:""`
RedisPassword string `envconfig:"REDIS_PASSWORD" required:"true"`
RedisDB int `envconfig:"REDIS_DB" default:"0"`
RedisStreamDB int `envconfig:"REDIS_STREAM_DB" default:"1"`
Expand Down
2 changes: 2 additions & 0 deletions diode-server/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func setupEnv(redisAddr string) {
_ = os.Setenv("GRPC_PORT", grpcPort)
_ = os.Setenv("REDIS_HOST", host)
_ = os.Setenv("REDIS_PORT", port)
_ = os.Setenv("REDIS_USERNAME", "")
_ = os.Setenv("REDIS_PASSWORD", "")
_ = os.Setenv("REDIS_DB", "0")
_ = os.Setenv("REDIS_STREAM_DB", "1")
Expand All @@ -49,6 +50,7 @@ func teardownEnv() {
_ = os.Unsetenv("GRPC_PORT")
_ = os.Unsetenv("REDIS_HOST")
_ = os.Unsetenv("REDIS_PORT")
_ = os.Unsetenv("REDIS_USERNAME")
_ = os.Unsetenv("REDIS_PASSWORD")
_ = os.Unsetenv("REDIS_DB")
_ = os.Unsetenv("REDIS_STREAM_DB")
Expand Down
8 changes: 6 additions & 2 deletions diode-server/reconciler/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ func NewServer(ctx context.Context, logger *slog.Logger, repository Repository,
return nil, fmt.Errorf("failed to create TLS config for Redis: %v", err)
}

redisClient := redis.NewClient(&redis.Options{
redisOptions := redis.Options{
Addr: fmt.Sprintf("%s:%s", cfg.RedisHost, cfg.RedisPort),
Password: cfg.RedisPassword,
DB: cfg.RedisDB,
TLSConfig: redisTLSConfig,
})
}
if cfg.RedisUsername != "" {
redisOptions.Username = cfg.RedisUsername
}
redisClient := redis.NewClient(&redisOptions)

if _, err := redisClient.Ping(ctx).Result(); err != nil {
return nil, fmt.Errorf("failed connection to %s: %v", redisClient.String(), err)
Expand Down
Loading