From 12bc41fd46b78de42324b81a137173bb7def79ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=C3=A9o=20Colombaro?= <git@colombaro.fr>
Date: Sat, 7 Sep 2024 20:30:15 +0000
Subject: [PATCH] Switch from Redis to Valkey

---
 README.md                                     | 20 ++++++-------
 charts/netbox/Chart.lock                      |  8 +++---
 charts/netbox/Chart.yaml                      |  6 ++--
 charts/netbox/templates/_helpers.tpl          | 28 +++++++++----------
 charts/netbox/templates/configmap.yaml        | 12 ++++----
 .../{redis-secret.yaml => valkey-secret.yaml} |  4 +--
 charts/netbox/values.yaml                     | 24 ++++++++--------
 7 files changed, 51 insertions(+), 51 deletions(-)
 rename charts/netbox/templates/{redis-secret.yaml => valkey-secret.yaml} (83%)

diff --git a/README.md b/README.md
index 1eac5ac2..ef1ed47e 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ Always [use an existing Secret](#using-an-existing-secret) and supply all
 passwords and secret keys yourself to avoid Helm re-generating any of them for
 you.
 
-We recommend setting both `postgresql.enabled` and `redis.enabled` to
+We recommend setting both `postgresql.enabled` and `valkey.enabled` to
 `false` and using a separate external PostgreSQL and Redis instance. This
 de-couples those services from the chart's bundled versions which may have
 complex upgrade requirements. A clustered PostgreSQL server (e.g. using Zalando's
@@ -214,13 +214,13 @@ The following table lists the configurable parameters for this chart and their d
 | `externalDatabase.connMaxAge`                   | The lifetime of a database connection, as an integer of seconds     | `300`                                        |
 | `externalDatabase.disableServerSideCursors`     | Disable the use of server-side cursors transaction pooling          | `false`                                      |
 | `externalDatabase.targetSessionAttrs`           | Determines whether the session must have certain properties         | `read-write`                                 |
-| `redis.enabled`                                 | Deploy Redis using bundled Bitnami Redis chart                      | `true`                                       |
-| `redis.*`                                       | Values under this key are passed to the bundled Redis chart         | n/a                                          |
-| `tasksRedis.database`                           | Redis database number used for NetBox task queue                    | `0`                                          |
-| `tasksRedis.ssl`                                | Enable SSL when connecting to Redis                                 | `false`                                      |
+| `valkey.enabled`                                 | Deploy Valkey using bundled Bitnami Valkey chart                      | `true`                                       |
+| `valkey.*`                                       | Values under this key are passed to the bundled Valkey chart         | n/a                                          |
+| `tasksRedis.database`                           | Redis/Valkey database number used for NetBox task queue                    | `0`                                          |
+| `tasksRedis.ssl`                                | Enable SSL when connecting to Redis/Valkey                                 | `false`                                      |
 | `tasksRedis.insecureSkipTlsVerify`              | Skip TLS certificate verification when connecting to Redis          | `false`                                      |
 | `tasksRedis.caCertPath`                         | Path to CA certificates bundle for Redis (needs mounting manually)  | `""`                                         |
-| `tasksRedis.host`                               | Redis host to use when `redis.enabled` is `false`                   | `"netbox-redis"`                             |
+| `tasksRedis.host`                               | Redis host to use when `valkey.enabled` is `false`                   | `"netbox-redis"`                             |
 | `tasksRedis.port`                               | Port number for external Redis                                      | `6379`                                       |
 | `tasksRedis.sentinels`                          | List of sentinels in `host:port` form (`host` and `port` not used)  | `[]`                                         |
 | `tasksRedis.sentinelService`                    | Sentinel master service name                                        | `"netbox-redis"`                             |
@@ -233,7 +233,7 @@ The following table lists the configurable parameters for this chart and their d
 | `cachingRedis.ssl`                              | Enable SSL when connecting to Redis                                 | `false`                                      |
 | `cachingRedis.insecureSkipTlsVerify`            | Skip TLS certificate verification when connecting to Redis          | `false`                                      |
 | `cachingRedis.caCertPath`                       | Path to CA certificates bundle for Redis (needs mounting manually)  | `""`                                         |
-| `cachingRedis.host`                             | Redis host to use when `redis.enabled` is `false`                   | `"netbox-redis"`                             |
+| `cachingRedis.host`                             | Redis host to use when `valkey.enabled` is `false`                   | `"netbox-redis"`                             |
 | `cachingRedis.port`                             | Port number for external Redis                                      | `6379`                                       |
 | `cachingRedis.sentinels`                        | List of sentinels in `host:port` form (`host` and `port` not used)  | `[]`                                         |
 | `cachingRedis.sentinelService`                  | Sentinel master service name                                        | `"netbox-redis"`                             |
@@ -458,7 +458,7 @@ Type: `kubernetes.io/basic-auth`
 
 | Key                    | Description                                                   | Required?                                                                                         |
 | -----------------------|---------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
-| `redis-password`       | Password for the external Redis database (tasks and/or cache) | If `redis.enabled` is `false`                                                                     |
+| `redis-password`       | Password for the external Redis database (tasks and/or cache) | If `valkey.enabled` is `false`                                                                     |
 
 ## Authentication
 * [Single Sign On](docs/auth.md#configuring-sso)
@@ -480,7 +480,7 @@ Type: `kubernetes.io/basic-auth`
   * NAPALM support has been moved into a plugin since NetBox 3.5, so all NAPALM configuration has been **removed from this chart**.
   * Please consult the [NetBox](https://docs.netbox.dev/en/stable/release-notes/) and [netbox-docker](https://github.com/netbox-community/netbox-docker) release notes in case there are any other changes that may affect your configuration.
 * The Bitnami [PostgreSQL](https://github.com/bitnami/charts/tree/main/bitnami/postgresql) sub-chart was upgraded from 10.x to 15.x; please read the upstream upgrade notes if you are using the bundled PostgreSQL.
-* The Bitnami [Redis](https://github.com/bitnami/charts/tree/main/bitnami/redis) sub-chart was upgraded from 15.x to 20.x; please read the upstream upgrade notes if you are using the bundled Redis.
+* The Bitnami [Redis](https://github.com/bitnami/charts/tree/main/bitnami/redis) sub-chart was upgraded from 15.x to 20.x; please read the upstream upgrade notes if you are using the bundled valkey.
 
 ### From 3.x to 4.x
 
@@ -503,7 +503,7 @@ Type: `kubernetes.io/basic-auth`
 ### From 1.x to 2.x
 
 If you use an external Redis you will need to update your configuration values
-due to the chart reflecting upstream changes in how it uses Redis. There are
+due to the chart reflecting upstream changes in how it uses valkey. There are
 now separate Redis configuration blocks for webhooks and for caching, though
 they can both point at the same Redis instance as long as the database numbers
 are different.
diff --git a/charts/netbox/Chart.lock b/charts/netbox/Chart.lock
index 226cabcb..1ad87dcb 100644
--- a/charts/netbox/Chart.lock
+++ b/charts/netbox/Chart.lock
@@ -5,8 +5,8 @@ dependencies:
 - name: postgresql
   repository: oci://registry-1.docker.io/bitnamicharts
   version: 15.5.32
-- name: redis
+- name: valkey
   repository: oci://registry-1.docker.io/bitnamicharts
-  version: 20.1.3
-digest: sha256:a43209a9ffc22c87e529814a5c112966e25af59c86c9cea527fd9e11bb8c4534
-generated: "2024-09-18T19:42:51.803744033Z"
+  version: 0.3.17
+digest: sha256:f2283a174981f5d9335843817022f493235d4135b31366597abd06f6749741fd
+generated: "2024-09-18T20:16:07.436740974Z"
diff --git a/charts/netbox/Chart.yaml b/charts/netbox/Chart.yaml
index edcea6eb..51bff860 100644
--- a/charts/netbox/Chart.yaml
+++ b/charts/netbox/Chart.yaml
@@ -25,10 +25,10 @@ dependencies:
     version: ^15.5.32
     repository: oci://registry-1.docker.io/bitnamicharts
     condition: postgresql.enabled
-  - name: redis
-    version: ^20.1.3
+  - name: valkey
+    version: ^0.3.17
     repository: oci://registry-1.docker.io/bitnamicharts
-    condition: redis.enabled
+    condition: valkey.enabled
 annotations:
   artifacthub.io/license: Apache-2.0
   artifacthub.io/links: |
diff --git a/charts/netbox/templates/_helpers.tpl b/charts/netbox/templates/_helpers.tpl
index 2ffb275b..446844eb 100644
--- a/charts/netbox/templates/_helpers.tpl
+++ b/charts/netbox/templates/_helpers.tpl
@@ -50,22 +50,22 @@ Name of the key in Secret that contains the PostgreSQL password
 {{- end }}
 
 {{/*
-Name of the Secret that contains the Redis tasks password
+Name of the Secret that contains the Valkey tasks password
 */}}
 {{- define "netbox.tasksRedis.secret" -}}
-  {{- if .Values.redis.enabled }}
-    {{- include "redis.secretName" .Subcharts.redis -}}
+  {{- if .Values.valkey.enabled }}
+    {{- include "valkey.secretName" .Subcharts.valkey -}}
   {{- else }}
-    {{- include "common.secrets.name" (dict "existingSecret" .Values.tasksRedis.existingSecretName "defaultNameSuffix" "redis" "context" $) }}
+    {{- include "common.secrets.name" (dict "existingSecret" .Values.tasksRedis.existingSecretName "defaultNameSuffix" "valkey" "context" $) }}
   {{- end }}
 {{- end }}
 
 {{/*
-Name of the key in Secret that contains the Redis tasks password
+Name of the key in Secret that contains the Valkey tasks password
 */}}
 {{- define "netbox.tasksRedis.secretKey" -}}
-  {{- if .Values.redis.enabled -}}
-    {{- include "redis.secretPasswordKey" .Subcharts.redis -}}
+  {{- if .Values.valkey.enabled -}}
+    {{- include "valkey.secretPasswordKey" .Subcharts.valkey -}}
   {{- else if .Values.tasksRedis.existingSecretName -}}
     {{ .Values.tasksRedis.existingSecretKey }}
   {{- else -}}
@@ -74,22 +74,22 @@ Name of the key in Secret that contains the Redis tasks password
 {{- end }}
 
 {{/*
-Name of the Secret that contains the Redis cache password
+Name of the Secret that contains the Valkey cache password
 */}}
 {{- define "netbox.cachingRedis.secret" -}}
-  {{- if .Values.redis.enabled }}
-    {{- include "redis.secretName" .Subcharts.redis -}}
+  {{- if .Values.valkey.enabled }}
+    {{- include "valkey.secretName" .Subcharts.valkey -}}
   {{- else }}
-    {{- include "common.secrets.name" (dict "existingSecret" .Values.cachingRedis.existingSecretName "defaultNameSuffix" "redis" "context" $) }}
+    {{- include "common.secrets.name" (dict "existingSecret" .Values.cachingRedis.existingSecretName "defaultNameSuffix" "valkey" "context" $) }}
   {{- end }}
 {{- end }}
 
 {{/*
-Name of the key in Secret that contains the Redis cache password
+Name of the key in Secret that contains the Valkey cache password
 */}}
 {{- define "netbox.cachingRedis.secretKey" -}}
-  {{- if .Values.redis.enabled -}}
-    {{- include "redis.secretPasswordKey" .Subcharts.redis -}}
+  {{- if .Values.valkey.enabled -}}
+    {{- include "valkey.secretPasswordKey" .Subcharts.valkey -}}
   {{- else if .Values.cachingRedis.existingSecretName -}}
     {{ .Values.cachingRedis.existingSecretKey }}
   {{- else -}}
diff --git a/charts/netbox/templates/configmap.yaml b/charts/netbox/templates/configmap.yaml
index bae02d69..786f4eb7 100644
--- a/charts/netbox/templates/configmap.yaml
+++ b/charts/netbox/templates/configmap.yaml
@@ -115,9 +115,9 @@ data:
 
     REDIS:
       tasks:
-        {{- if .Values.redis.enabled }}
-        HOST: {{ printf "%s-master" (include "common.names.fullname" .Subcharts.redis) | quote }}
-        PORT: {{ .Values.redis.master.service.ports.redis | int }}
+        {{- if .Values.valkey.enabled }}
+        HOST: {{ printf "%s-master" (include "common.names.fullname" .Subcharts.valkey) | quote }}
+        PORT: {{ .Values.valkey.master.service.ports.valkey | int }}
         {{- else if .Values.tasksRedis.sentinels }}
         SENTINELS: {{ toJson .Values.tasksRedis.sentinels }}
         SENTINEL_SERVICE: {{ .Values.tasksRedis.sentinelService | quote }}
@@ -132,9 +132,9 @@ data:
         INSECURE_SKIP_TLS_VERIFY: {{ toJson .Values.tasksRedis.insecureSkipTlsVerify }}
         CA_CERT_PATH: {{ .Values.tasksRedis.caCertPath | quote }}
       caching:
-        {{- if .Values.redis.enabled }}
-        HOST: {{ printf "%s-master" (include "common.names.fullname" .Subcharts.redis) | quote }}
-        PORT: {{ .Values.redis.master.service.ports.redis | int }}
+        {{- if .Values.valkey.enabled }}
+        HOST: {{ printf "%s-master" (include "common.names.fullname" .Subcharts.valkey) | quote }}
+        PORT: {{ .Values.valkey.master.service.ports.valkey | int }}
         {{- else if .Values.cachingRedis.sentinels }}
         SENTINELS: {{ toJson .Values.cachingRedis.sentinels }}
         SENTINEL_SERVICE: {{ .Values.cachingRedis.sentinelService | quote }}
diff --git a/charts/netbox/templates/redis-secret.yaml b/charts/netbox/templates/valkey-secret.yaml
similarity index 83%
rename from charts/netbox/templates/redis-secret.yaml
rename to charts/netbox/templates/valkey-secret.yaml
index 039e1bd7..40bd19c3 100644
--- a/charts/netbox/templates/redis-secret.yaml
+++ b/charts/netbox/templates/valkey-secret.yaml
@@ -1,8 +1,8 @@
-{{- if not (or .Values.redis.enabled (and .Values.tasksRedis.existingSecretName .Values.cachingRedis.existingSecretName)) -}}
+{{- if not (or .Values.valkey.enabled (and .Values.tasksRedis.existingSecretName .Values.cachingRedis.existingSecretName)) -}}
 apiVersion: v1
 kind: Secret
 metadata:
-  name: {{ include "common.secrets.name" (dict "defaultNameSuffix" "redis" "context" $) }}
+  name: {{ include "common.secrets.name" (dict "defaultNameSuffix" "valkey" "context" $) }}
   namespace: {{ include "common.names.namespace" . | quote }}
   labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
   {{- if .Values.commonAnnotations }}
diff --git a/charts/netbox/values.yaml b/charts/netbox/values.yaml
index 6b6e82ce..48f03a8f 100644
--- a/charts/netbox/values.yaml
+++ b/charts/netbox/values.yaml
@@ -1020,11 +1020,11 @@ externalDatabase:
   disableServerSideCursors: false
   targetSessionAttrs: read-write
 
-## Redis chart configuration
-## https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml
-## @param redis.enabled Deploy Redis using bundled Bitnami Redis chart
+## Valkey chart configuration
+## https://github.com/bitnami/charts/blob/main/bitnami/valkey/values.yaml
+## @param valkey.enabled Whether to deploy a Valkey server to satisfy the applications database requirements
 ##
-redis:
+valkey:
   enabled: true
 
 tasksRedis:
@@ -1033,18 +1033,18 @@ tasksRedis:
   insecureSkipTlsVerify: false
   caCertPath: ""
 
-  # Used only when redis.enabled is false. host and port are not used if
+  # Used only when valkey.enabled is false. host and port are not used if
   # sentinels are given.
-  host: netbox-redis
+  host: netbox-valkey
   port: 6379
   sentinels: []
   #  - mysentinel:26379
-  sentinelService: netbox-redis
+  sentinelService: netbox-valkey
   sentinelTimeout: 300
   username: ""
   password: ""
   existingSecretName: ""
-  existingSecretKey: redis-password
+  existingSecretKey: valkey-password
 
 cachingRedis:
   database: 1
@@ -1052,18 +1052,18 @@ cachingRedis:
   insecureSkipTlsVerify: false
   caCertPath: ""
 
-  # Used only when redis.enabled is false. host and port are not used if
+  # Used only when valkey.enabled is false. host and port are not used if
   # sentinels are given.
-  host: netbox-redis
+  host: netbox-valkey
   port: 6379
   sentinels: []
   #  - mysentinel:26379
-  sentinelService: netbox-redis
+  sentinelService: netbox-valkey
   sentinelTimeout: 300
   username: ""
   password: ""
   existingSecretName: ""
-  existingSecretKey: redis-password
+  existingSecretKey: valkey-password
 
 ## @section Autoscaling parameters