Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.
- 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
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.2687@sha256:1e113d9625cee4d32b995bb199ca7d6b6f5db1907404acc8ce9b272d39714963
# -- 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