From 998bb3ec3a445e16296364cb19cd3d54a272f4bf Mon Sep 17 00:00:00 2001 From: Marc LeBlanc Date: Wed, 10 Dec 2025 13:32:52 -0700 Subject: [PATCH 1/3] Fix the chomp, and expand use cases note --- charts/sourcegraph/templates/_helpers.tpl | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/charts/sourcegraph/templates/_helpers.tpl b/charts/sourcegraph/templates/_helpers.tpl index c1671edd..64227cc1 100644 --- a/charts/sourcegraph/templates/_helpers.tpl +++ b/charts/sourcegraph/templates/_helpers.tpl @@ -249,19 +249,33 @@ app.kubernetes.io/name: jaeger {{- end }} {{/* -Set redisCache and redisStore endpoints -So that customers can configure them any of these ways: +Set redisCache and redisStore endpoints, +so that customers can configure them any of these ways: + 1. Create a new Kubernetes secret, with default values (default, no override config required) + 2. Use an existing Kubernetes secret, by configuring .Values.redisCache.connection.existingSecret + 3. Do not create or use Kubernetes secrets, just pass the default values directly as environment variables into the needed pods, by configuring .Values.sourcegraph.disableKubernetesSecrets = true -4. Do not create or use Kubernetes secrets, but pass custom values (ex. external Redis) directly as environment variables into the needed pods, by configuring .Values.sourcegraph.disableKubernetesSecrets = true, .Values.redisCache.connection.endpoint = "", .Values.redisStore.connection.endpoint = "", and defining the REDIS_CACHE_ENDPOINT and REDIS_STORE_ENDPOINT env vars on frontend, gitserver, searcher, and worker pods + +4. Do not create or use Kubernetes secrets, but provide custom values (ex. external Redis) to have this function pass them into the REDIS_CACHE_ENDPOINT and REDIS_STORE_ENDPOINT env vars on frontend, gitserver, searcher, and worker pods, by configuring: +.Values.sourcegraph.disableKubernetesSecrets = true, +.Values.redisCache.connection.endpoint = , +.Values.redisStore.connection.endpoint = , + +5. Do not create or use Kubernetes secrets, but pass custom values (ex. external Redis) directly as environment variables into the needed pods, by configuring: +.Values.sourcegraph.disableKubernetesSecrets = true, +.Values.redisCache.connection.endpoint = "", +.Values.redisStore.connection.endpoint = "", +and defining the REDIS_CACHE_ENDPOINT and REDIS_STORE_ENDPOINT env vars on frontend, gitserver, searcher, and worker pods + */}} {{- define "sourcegraph.redisConnection" -}} {{- if .Values.sourcegraph.disableKubernetesSecrets -}} {{- if .Values.redisCache.connection.endpoint -}} - name: REDIS_CACHE_ENDPOINT value: {{ .Values.redisCache.connection.endpoint }} -{{- end -}} +{{ end -}} {{- if .Values.redisStore.connection.endpoint -}} - name: REDIS_STORE_ENDPOINT value: {{ .Values.redisStore.connection.endpoint }} From b21c000eaf666323f196fc8f2d1b619e59e6f688 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc Date: Sun, 14 Dec 2025 22:26:57 -0700 Subject: [PATCH 2/3] Update comments and spacing --- charts/sourcegraph/templates/_helpers.tpl | 19 +++++++++++-------- .../searcher/searcher.StatefulSet.yaml | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/charts/sourcegraph/templates/_helpers.tpl b/charts/sourcegraph/templates/_helpers.tpl index 64227cc1..f5c29b1a 100644 --- a/charts/sourcegraph/templates/_helpers.tpl +++ b/charts/sourcegraph/templates/_helpers.tpl @@ -254,19 +254,22 @@ so that customers can configure them any of these ways: 1. Create a new Kubernetes secret, with default values (default, no override config required) -2. Use an existing Kubernetes secret, by configuring .Values.redisCache.connection.existingSecret +2. Use an existing Kubernetes secret, by configuring: +.Values.redisCache.connection.existingSecret: , +.Values.redisStore.connection.existingSecret: , -3. Do not create or use Kubernetes secrets, just pass the default values directly as environment variables into the needed pods, by configuring .Values.sourcegraph.disableKubernetesSecrets = true +3. Do not create or use Kubernetes secrets, just pass the default values directly as environment variables into the needed pods, by configuring: +.Values.sourcegraph.disableKubernetesSecrets: true 4. Do not create or use Kubernetes secrets, but provide custom values (ex. external Redis) to have this function pass them into the REDIS_CACHE_ENDPOINT and REDIS_STORE_ENDPOINT env vars on frontend, gitserver, searcher, and worker pods, by configuring: -.Values.sourcegraph.disableKubernetesSecrets = true, -.Values.redisCache.connection.endpoint = , -.Values.redisStore.connection.endpoint = , +.Values.sourcegraph.disableKubernetesSecrets: true, +.Values.redisCache.connection.endpoint: , +.Values.redisStore.connection.endpoint: , 5. Do not create or use Kubernetes secrets, but pass custom values (ex. external Redis) directly as environment variables into the needed pods, by configuring: -.Values.sourcegraph.disableKubernetesSecrets = true, -.Values.redisCache.connection.endpoint = "", -.Values.redisStore.connection.endpoint = "", +.Values.sourcegraph.disableKubernetesSecrets: true, +.Values.redisCache.connection.endpoint: "", +.Values.redisStore.connection.endpoint: "", and defining the REDIS_CACHE_ENDPOINT and REDIS_STORE_ENDPOINT env vars on frontend, gitserver, searcher, and worker pods */}} diff --git a/charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml b/charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml index ab201aeb..dcecd46e 100644 --- a/charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml +++ b/charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml @@ -50,8 +50,8 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} env: - {{- include "sourcegraph.redisConnection" .| nindent 8 }} - {{- range $name, $item := .Values.searcher.env}} + {{- include "sourcegraph.redisConnection" . | nindent 8 }} + {{- range $name, $item := .Values.searcher.env }} - name: {{ $name }} {{- $item | toYaml | nindent 10 }} {{- end }} From 40f9be986d29683e2da7ddd86dbf60774b4b0dc0 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc Date: Mon, 15 Dec 2025 01:52:05 -0700 Subject: [PATCH 3/3] Remove extra blank lines, witout overchomping --- charts/sourcegraph/templates/_helpers.tpl | 2 ++ charts/sourcegraph/templates/_worker.tpl | 2 +- .../templates/frontend/sourcegraph-frontend.Deployment.yaml | 4 ++-- .../templates/gitserver/gitserver.StatefulSet.yaml | 2 +- .../sourcegraph/templates/searcher/searcher.StatefulSet.yaml | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/charts/sourcegraph/templates/_helpers.tpl b/charts/sourcegraph/templates/_helpers.tpl index f5c29b1a..26d15e0e 100644 --- a/charts/sourcegraph/templates/_helpers.tpl +++ b/charts/sourcegraph/templates/_helpers.tpl @@ -278,7 +278,9 @@ and defining the REDIS_CACHE_ENDPOINT and REDIS_STORE_ENDPOINT env vars on front {{- if .Values.redisCache.connection.endpoint -}} - name: REDIS_CACHE_ENDPOINT value: {{ .Values.redisCache.connection.endpoint }} +{{- if .Values.redisStore.connection.endpoint }} {{/*Add whitespace only if both are defined*/}} {{ end -}} +{{- end -}} {{- if .Values.redisStore.connection.endpoint -}} - name: REDIS_STORE_ENDPOINT value: {{ .Values.redisStore.connection.endpoint }} diff --git a/charts/sourcegraph/templates/_worker.tpl b/charts/sourcegraph/templates/_worker.tpl index 73c4b64a..5b6166c0 100644 --- a/charts/sourcegraph/templates/_worker.tpl +++ b/charts/sourcegraph/templates/_worker.tpl @@ -66,7 +66,7 @@ spec: containers: - name: worker env: - {{- include "sourcegraph.redisConnection" $top | nindent 8 }} + {{- with include "sourcegraph.redisConnection" $top | trim }}{{ . | nindent 8 }}{{- end }} {{- if $allowlist }} - name: WORKER_JOB_ALLOWLIST value: {{ $allowlist }} diff --git a/charts/sourcegraph/templates/frontend/sourcegraph-frontend.Deployment.yaml b/charts/sourcegraph/templates/frontend/sourcegraph-frontend.Deployment.yaml index e0f61903..a6b9a25f 100644 --- a/charts/sourcegraph/templates/frontend/sourcegraph-frontend.Deployment.yaml +++ b/charts/sourcegraph/templates/frontend/sourcegraph-frontend.Deployment.yaml @@ -65,7 +65,7 @@ spec: {{- range $name, $item := .Values.migrator.env }} - name: {{ $name }} {{- $item | toYaml | nindent 10 }} - {{- end }} + {{- end }} {{- if not .Values.sourcegraph.localDevMode}} resources: {{- toYaml .Values.migrator.resources | nindent 10 }} @@ -95,7 +95,7 @@ spec: - name: {{ $name }} {{- $item | toYaml | nindent 10 }} {{- end }} - {{- include "sourcegraph.redisConnection" .| nindent 8 }} + {{- with include "sourcegraph.redisConnection" . | trim }}{{ . | nindent 8 }}{{- end }} {{- include "sourcegraph.openTelemetryEnv" . | nindent 8 }} {{- if .Values.blobstore.enabled }} - name: PRECISE_CODE_INTEL_UPLOAD_BACKEND diff --git a/charts/sourcegraph/templates/gitserver/gitserver.StatefulSet.yaml b/charts/sourcegraph/templates/gitserver/gitserver.StatefulSet.yaml index 9620df24..b8272448 100644 --- a/charts/sourcegraph/templates/gitserver/gitserver.StatefulSet.yaml +++ b/charts/sourcegraph/templates/gitserver/gitserver.StatefulSet.yaml @@ -49,7 +49,7 @@ spec: image: {{ include "sourcegraph.image" (list . "gitserver") }} imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }} env: - {{- include "sourcegraph.redisConnection" .| nindent 8 }} + {{- with include "sourcegraph.redisConnection" . | trim }}{{ . | nindent 8 }}{{- end }} {{- range $name, $item := .Values.gitserver.env}} - name: {{ $name }} {{- $item | toYaml | nindent 10 }} diff --git a/charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml b/charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml index dcecd46e..4d5342fa 100644 --- a/charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml +++ b/charts/sourcegraph/templates/searcher/searcher.StatefulSet.yaml @@ -50,7 +50,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} env: - {{- include "sourcegraph.redisConnection" . | nindent 8 }} + {{- with include "sourcegraph.redisConnection" . | trim }}{{ . | nindent 8 }}{{- end }} {{- range $name, $item := .Values.searcher.env }} - name: {{ $name }} {{- $item | toYaml | nindent 10 }}