Skip to content
Closed
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
29 changes: 24 additions & 5 deletions charts/sourcegraph/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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: <secret name>,
.Values.redisStore.connection.existingSecret: <secret name>,

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: <custom value for REDIS_CACHE_ENDPOINT>,
.Values.redisStore.connection.endpoint: <custom value for REDIS_STORE_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
Expand Down
2 changes: 1 addition & 1 deletion charts/sourcegraph/templates/_worker.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Loading