diff --git a/charts/sourcegraph/templates/_helpers.tpl b/charts/sourcegraph/templates/_helpers.tpl index c1671edd..26d15e0e 100644 --- a/charts/sourcegraph/templates/_helpers.tpl +++ b/charts/sourcegraph/templates/_helpers.tpl @@ -249,18 +249,37 @@ 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 + +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 + +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 }} +{{- if .Values.redisStore.connection.endpoint }} {{/*Add whitespace only if both are defined*/}} +{{ end -}} {{- end -}} {{- if .Values.redisStore.connection.endpoint -}} - name: REDIS_STORE_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 ab201aeb..4d5342fa 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}} + {{- with include "sourcegraph.redisConnection" . | trim }}{{ . | nindent 8 }}{{- end }} + {{- range $name, $item := .Values.searcher.env }} - name: {{ $name }} {{- $item | toYaml | nindent 10 }} {{- end }}