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 @@ -8,6 +8,7 @@ Use `**BREAKING**:` to denote a breaking change

## Unreleased

- 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
- 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`.
Expand Down
8 changes: 3 additions & 5 deletions charts/sourcegraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ In addition to the documented values, all services also support the following va

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| alpine.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":999,"runAsUser":999}` | Security context for the `alpine` initContainer, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
| alpine.image.defaultTag | string | `<appVersion>@sha256:<digest>`, pinned by each release | Docker image tag for the `alpine` image |
| alpine.image.name | string | `"alpine-3.14"` | Docker image name for the `alpine` image |
| alpine.resources | object | `{"limits":{"cpu":"10m","memory":"50Mi"},"requests":{"cpu":"10m","memory":"50Mi"}}` | Resource requests & limits for the `alpine` initContainer, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| alpine.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":999,"runAsUser":999}` | Security context for the `correct-data-dir-permissions` initContainer of `pgsql` and `codeintel-db`, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
| alpine.resources | object | `{"limits":{"cpu":"10m","memory":"50Mi"},"requests":{"cpu":"10m","memory":"50Mi"}}` | Resource requests & limits for the `correct-data-dir-permissions` initContainer of `pgsql`, `codeintel-db`, and `codeinsights-db`, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| blobstore.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"runAsGroup":101,"runAsUser":100}` | Security context for the `blobstore` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
| blobstore.enabled | bool | `true` | Enable `blobstore` (S3 compatible storage) |
| blobstore.env | object | the chart will add some default environment values | Environment variables for the `blobstore` container |
Expand Down Expand Up @@ -128,7 +126,7 @@ In addition to the documented values, all services also support the following va
| codeInsightsDB.existingConfig | string | `""` | Name of existing ConfigMap for `codeinsights-db`. It must contain a `postgresql.conf` key. |
| codeInsightsDB.image.defaultTag | string | `<appVersion>@sha256:<digest>`, pinned by each release | Docker image tag for the `codeinsights-db` image |
| codeInsightsDB.image.name | string | `"postgresql-16-codeinsights"` | Docker image name for the `codeinsights-db` image |
| codeInsightsDB.init.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":70,"runAsUser":70}` | Security context for the `alpine` initContainer, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
| codeInsightsDB.init.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":70,"runAsUser":70}` | Security context for the `correct-data-dir-permissions` initContainer, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
| codeInsightsDB.name | string | `"codeinsights-db"` | Name used by resources. Does not affect service names or PVCs. |
| codeInsightsDB.podSecurityContext | object | `{"fsGroup":70,"fsGroupChangePolicy":"OnRootMismatch","runAsUser":70}` | Security context for the `codeinsights-db` pod, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod) |
| codeInsightsDB.postgresExporter | object | `{}` | Configuration for the `pgsql-exporter` sidecar container |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# image: custom-repo.ecr.us-east-1.amazonaws.com/sourcegraph/frontend:3.35.1
#
# Original image reference:
# image: index.docker.io/sourcegraph/alpine-3.12:3.35.1@sha256:a26a8820b8794c2d85c67f7b61b00b4d468af722047b8093235a827c08ea878a
# image: index.docker.io/sourcegraph/postgresql-16:3.35.1@sha256:<digest>
#
# Using override, with custom image name:
# image: custom-repo.ecr.us-east-1.amazonaws.com/sourcegraph/alpine:3.12
# image: custom-repo.ecr.us-east-1.amazonaws.com/sourcegraph/sg-postgresql-16:3.35.1

sourcegraph:
image:
Expand All @@ -21,10 +21,9 @@ sourcegraph:
imagePullSecrets:
- name: regcred # Pre-existing secret that contains the credentials needed to pull from the image registry

alpine:
pgsql:
image:
name: alpine # Use a custom name instead of the Sourcegraph name - i.e. alpine-3.12
tag: 3.12 # Use a custom tag instead of the default - i.e. 3.35.1
name: sg-postgresql-16 # Use a custom name instead of the Sourcegraph name - i.e. postgresql-16

# Allow Executors to reuse the same registry credentials to pull the needed images for Batch Changes and Auto-indexing
executor:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
{{- toYaml . | nindent 6 }}
{{- end }}
- name: correct-data-dir-permissions
image: {{ include "sourcegraph.image" (list . "alpine") }}
image: {{ include "sourcegraph.image" (list . "codeInsightsDB") }}
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
command: ["sh", "-c", "if [ -d /var/lib/postgresql/data/pgdata ]; then chmod 750 /var/lib/postgresql/data/pgdata; fi"]
volumeMounts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
{{- toYaml . | nindent 6 }}
{{- end }}
- name: correct-data-dir-permissions
image: {{ include "sourcegraph.image" (list . "alpine") }}
image: {{ include "sourcegraph.image" (list . "codeIntelDB") }}
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
command: ["sh", "-c", "if [ -d /data/pgdata-12 ]; then chmod 750 /data/pgdata-12; fi"]
volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion charts/sourcegraph/templates/pgsql/pgsql.StatefulSet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
{{- toYaml . | nindent 6 }}
{{- end }}
- name: correct-data-dir-permissions
image: {{ include "sourcegraph.image" (list . "alpine") }}
image: {{ include "sourcegraph.image" (list . "pgsql") }}
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
command: ["sh", "-c", "if [ -d /data/pgdata-12 ]; then chmod 750 /data/pgdata-12; fi"]
volumeMounts:
Expand Down
38 changes: 38 additions & 0 deletions charts/sourcegraph/tests/dataDirPermissionsInitContainer_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
suite: dataDirPermissionsInitContainer
release:
name: sourcegraph
namespace: sourcegraph
tests:
- it: should run the pgsql init container on the pgsql image
template: pgsql/pgsql.StatefulSet.yaml
set:
pgsql:
image:
name: custom-postgres
defaultTag: test
asserts:
- equal:
path: spec.template.spec.initContainers[?(@.name == "correct-data-dir-permissions")].image
value: index.docker.io/sourcegraph/custom-postgres:test
- it: should run the codeintel-db init container on the codeintel-db image
template: codeintel-db/codeintel-db.StatefulSet.yaml
set:
codeIntelDB:
image:
name: custom-postgres
defaultTag: test
asserts:
- equal:
path: spec.template.spec.initContainers[?(@.name == "correct-data-dir-permissions")].image
value: index.docker.io/sourcegraph/custom-postgres:test
- it: should run the codeinsights-db init container on the codeinsights-db image
template: codeinsights-db/codeinsights-db.StatefulSet.yaml
set:
codeInsightsDB:
image:
name: custom-postgres
defaultTag: test
asserts:
- equal:
path: spec.template.spec.initContainers[?(@.name == "correct-data-dir-permissions")].image
value: index.docker.io/sourcegraph/custom-postgres:test
14 changes: 4 additions & 10 deletions charts/sourcegraph/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,16 @@ sourcegraph:
# # Toggle deployment of applications on/off. Applies to databases and third-party applications
# enabled: true

# Used by the `correct-data-dir-permissions` initContainer of `pgsql` and `codeintel-db`, which runs the database's own image
alpine:
# Used in init containers
image:
# -- Docker image tag for the `alpine` image
# @default -- `<appVersion>@sha256:<digest>`, pinned by each release
defaultTag: 8.1.4873@sha256:8e42f8f9bf080d8d2be0f3ada324950a476d4185839de08f31fd3ce2697be5c4
# -- Docker image name for the `alpine` image
name: "alpine-3.14"
# -- Security context for the `alpine` initContainer,
# -- Security context for the `correct-data-dir-permissions` initContainer of `pgsql` and `codeintel-db`,
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container)
containerSecurityContext:
allowPrivilegeEscalation: false
runAsUser: 999
runAsGroup: 999
readOnlyRootFilesystem: true
# -- Resource requests & limits for the `alpine` initContainer,
# -- Resource requests & limits for the `correct-data-dir-permissions` initContainer of `pgsql`, `codeintel-db`, and `codeinsights-db`,
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
resources:
limits:
Expand Down Expand Up @@ -209,7 +203,7 @@ codeInsightsDB:
runAsGroup: 70
readOnlyRootFilesystem: true
init:
# -- Security context for the `alpine` initContainer,
# -- Security context for the `correct-data-dir-permissions` initContainer,
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container)
containerSecurityContext:
allowPrivilegeEscalation: false
Expand Down
Loading