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
1 change: 1 addition & 0 deletions charts/sourcegraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Use `**BREAKING**:` to denote a breaking change
- The `correct-data-dir-permissions` init containers of `pgsql`, `codeintel-db`, and `codeinsights-db` now run the database's own image instead of `sourcegraph/alpine-3.14`, which was based on an end-of-life Alpine release. The chart no longer pulls `alpine-3.14`, so private registries no longer need to mirror it. `alpine.image` has been removed and is ignored if set; `alpine.containerSecurityContext`, `alpine.resources`, and `codeInsightsDB.init.containerSecurityContext` still apply.
- Fixed `frontend.command` and `migrator.command` rendering a list as a single element, e.g. `["sh", "-c", "<script>"]` became `[sh -c <script>]`, so the container failed to start. Both are now rendered as YAML lists and documented in `values.yaml`. A string holding a YAML list, the only form that worked before, still renders unchanged.
- Added `openTelemetry.gateway.command` to replace the `otel-collector` container's command, e.g. with a shell wrapper that exports an exporter API key read from a mounted file
- Fixed `precise-code-intel-worker` and `syntactic-code-intel-worker` ignoring the chart's Redis connection settings. They now get `REDIS_CACHE_ENDPOINT` and `REDIS_STORE_ENDPOINT` from `redisCache.connection` and `redisStore.connection`, like `frontend`, `gitserver`, `searcher`, and `worker`, and restart when they change. Previously they always used their built-in default `redis-store:6379`, which does not exist on instances with external Redis. If you worked around this by setting either variable in `preciseCodeIntel.env` or `syntacticCodeIntel.env`, remove it when upgrading.
- Added `<serviceName>.extraInitContainers` to every workload, rendered before any init containers the chart defines, so e.g. a secrets-fetching init container on `frontend` runs before `migrator`. Use `restartPolicy: Always` for a native sidecar that must be started before the main container, such as one that writes a `grafana` datasource credential file read by `datasources.yml`.
- Added `<serviceName>.extraServicePorts` to append ports to each component's primary Service (`sourcegraph-frontend`, `indexed-search`, and `worker`, not `sourcegraph-frontend-internal`, `indexed-search-indexer`, or `worker-executors`), e.g. to expose a sidecar's port
- Removed the hardcoded `PRECISE_CODE_INTEL_UPLOAD_BACKEND=blobstore` and `PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT=http://blobstore:9000` environment variables from `frontend`, `worker`, `precise-code-intel-worker`, and `syntactic-code-intel-worker`. They matched Sourcegraph's built-in defaults, so default deployments are unchanged. `SOURCEGRAPH_UPLOAD_*` in `*.env` is now the only object storage configuration in the chart, as in the `external-object-storage` examples. Previously, with `blobstore.enabled: true`, the chart's values were rendered after `*.env` and overrode any `PRECISE_CODE_INTEL_UPLOAD_*` set there. Helm's three-way merge removes every duplicate of those names on this upgrade, including the `*.env` override, and the override is applied on the next `helm upgrade` after this one, when code-intel uploads switch to its bucket. Before that, make sure the bucket exists, or move the settings to `SOURCEGRAPH_UPLOAD_*`, or remove them. Run a second `helm upgrade` right away to make the switch at a known time.
Expand Down
2 changes: 1 addition & 1 deletion charts/sourcegraph/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ so that customers can configure them any of these ways:
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:
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, worker, precise-code-intel-worker, and syntactic-code-intel-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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
metadata:
annotations:
kubectl.kubernetes.io/default-container: precise-code-intel-worker
{{- include "sourcegraph.redisChecksum" . | nindent 8 }}
{{- if .Values.sourcegraph.podAnnotations }}
{{- toYaml .Values.sourcegraph.podAnnotations | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -58,6 +59,7 @@ spec:
- name: precise-code-intel-worker
env:
{{- include "sourcegraph.gracefulShutdownEnv" (list . "preciseCodeIntel") | nindent 8 }}
{{- include "sourcegraph.redisConnection" . | nindent 8 }}
{{- range $name, $item := .Values.preciseCodeIntel.env}}
- name: {{ $name }}
{{- $item | toYaml | nindent 10 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ spec:
metadata:
annotations:
kubectl.kubernetes.io/default-container: syntactic-code-intel-worker
{{- include "sourcegraph.redisChecksum" . | nindent 8 }}
{{- if .Values.sourcegraph.podAnnotations }}
{{- toYaml .Values.sourcegraph.podAnnotations | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -59,6 +60,7 @@ spec:
- name: syntactic-code-intel-worker
env:
{{- include "sourcegraph.gracefulShutdownEnv" (list . "syntacticCodeIntel") | nindent 8 }}
{{- include "sourcegraph.redisConnection" . | nindent 8 }}
{{- range $name, $item := .Values.syntacticCodeIntel.env}}
- name: {{ $name }}
{{- $item | toYaml | nindent 10 }}
Expand Down
36 changes: 35 additions & 1 deletion charts/sourcegraph/tests/redisConnection_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
suite: redisConnection
templates:
- frontend/sourcegraph-frontend.Deployment.yaml
- precise-code-intel/worker.Deployment.yaml
- syntactic-code-intel/worker.Deployment.yaml
set:
syntacticCodeIntel:
enabled: true
tests:
- it: should reference the default secret
asserts:
- exists:
path: spec.template.metadata.annotations["checksum/redis"]
- contains:
path: spec.template.spec.containers[0].env
content:
Expand All @@ -21,6 +28,31 @@ tests:
secretKeyRef:
key: endpoint
name: redis-store
- it: should reference existing secrets when .connection.existingSecret is set
set:
redisCache:
connection:
existingSecret: ext-cache
redisStore:
connection:
existingSecret: ext-store
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: REDIS_CACHE_ENDPOINT
valueFrom:
secretKeyRef:
key: endpoint
name: ext-cache
- contains:
path: spec.template.spec.containers[0].env
content:
name: REDIS_STORE_ENDPOINT
valueFrom:
secretKeyRef:
key: endpoint
name: ext-store
- it: should not reference secret when .sourcegraph.disableKubernetesSecrets is true
set:
sourcegraph:
Expand Down Expand Up @@ -53,5 +85,7 @@ tests:
connection:
endpoint: ""
asserts:
- failedTemplate:
# The render stops at the first error, and helm-unittest reports it on the last template in the suite.
- template: syntactic-code-intel/worker.Deployment.yaml
failedTemplate:
errorMessage: .Values.redisCache.connection.endpoint and .Values.redisStore.connection.endpoint must be set when disableKubernetesSecrets is true!
Loading