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
2 changes: 2 additions & 0 deletions charts/sourcegraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Use `**BREAKING**:` to denote a breaking change

## Unreleased

- 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`.
- 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
3 changes: 3 additions & 0 deletions charts/sourcegraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ In addition to the documented values, all services also support the following va
| codeIntelDB.storageSize | string | `"200Gi"` | PVC Storage Request for `codeintel-db` data volume |
| codeIntelDB.storageSubPath | string | `""` | Optional subPath for the `codeintel-db` primary data volume mount |
| extraResources | list | `[]` | Additional resources to include in the rendered manifest. Templates are supported. |
| frontend.command | list | `[]` | Command for the `frontend` container, as a list, replacing the image's entrypoint, e.g. a shell wrapper that exports credentials read from mounted files before starting `frontend`. `frontend.args` (default `["serve"]`) is still passed as the arguments. |
| frontend.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `frontend` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
| frontend.createRoleBinding | bool | `true` | Disable the roleBinding resource for deployment environments blocking RBAC, ex. OpenShift's default "secure" SCC |
| frontend.env | object | the chart will add some default environment values | Environment variables for the `frontend` container |
Expand Down Expand Up @@ -263,6 +264,7 @@ In addition to the documented values, all services also support the following va
| jaeger.resources | object | `{"limits":{"cpu":"1","memory":"1G"},"requests":{"cpu":"500m","memory":"500M"}}` | Resource requests & limits for the `jaeger` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| jaeger.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `jaeger` |
| jaeger.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
| migrator.command | list | `[]` | Command for the `migrator` init container, as a list, replacing the image's entrypoint. `migrator.args` (default `["up"]`) is still passed as the arguments. |
| migrator.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `migrator` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
| migrator.enabled | bool | `true` | Enable [migrator](https://docs.sourcegraph.com/admin/how-to/manual_database_migrations) initContainer in `frontend` deployment to perform database migration |
| migrator.env | object | the chart will add some default environment values | Environment variables for the `migrator` container |
Expand Down Expand Up @@ -293,6 +295,7 @@ In addition to the documented values, all services also support the following va
| openTelemetry.agent.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `otel-agent` |
| openTelemetry.agent.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
| openTelemetry.enabled | bool | `true` | |
| openTelemetry.gateway.command | list | `[]` | Command for the `otel-collector` container, as a list, replacing the chart's `/bin/otelcol-sourcegraph --config=<file>` command, including the `--config` flag the chart selects, e.g. a shell wrapper that exports an exporter API key read from a mounted file. `openTelemetry.gateway.args` is still passed as the arguments. |
| openTelemetry.gateway.config.traces.exporters | object | `{}` | Define where traces should be exported to. Read how to configure different backends in the [OpenTelemetry documentation](https://opentelemetry.io/docs/collector/configuration/#exporters) |
| openTelemetry.gateway.config.traces.exportersTlsSecretName | string | `""` | Define the name of a preexisting secret containing TLS certificates for exporters, which will be mounted under "/tls". Read more about TLS configuration of exporters in the [OpenTelemetry Collector documentation](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md) |
| openTelemetry.gateway.config.traces.processors | object | `{}` | Define trace processors. Read how to configure sampling in the [OpenTelemetry documentation](https://docs.sourcegraph.com/admin/observability/opentelemetry#sampling-traces) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ spec:
- name: migrator
image: {{ include "sourcegraph.image" (list . "migrator") }}
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
{{- if .Values.migrator.command }}
command: {{ .Values.migrator.command }}
{{- with .Values.migrator.command }}
command: {{- if kindIs "string" . }} {{ . }}{{ else }}{{ toYaml . | nindent 8 }}{{ end }}
{{- end }}
args: {{- default (list "up") .Values.migrator.args | toYaml | nindent 8 }}
env:
Expand Down Expand Up @@ -85,8 +85,8 @@ spec:
- name: frontend
image: {{ include "sourcegraph.image" (list . "frontend") }}
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
{{- if .Values.frontend.command }}
command: {{ .Values.frontend.command }}
{{- with .Values.frontend.command }}
command: {{- if kindIs "string" . }} {{ . }}{{ else }}{{ toYaml . | nindent 8 }}{{ end }}
{{- end }}
args: {{- default (list "serve") .Values.frontend.args | toYaml | nindent 8 }}
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ spec:
image: {{ include "sourcegraph.image" (list . "openTelemetry") }}
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
command:
{{- with .Values.openTelemetry.gateway.command }}
{{- toYaml . | nindent 10 }}
{{- else }}
- "/bin/otelcol-sourcegraph"
{{- if and (not .Values.openTelemetry.gateway.config.traces.exporters) (not .Values.jaeger.enabled) }} # default config: enable logging exporter
- "--config=/etc/otel-collector/configs/logging.yaml"
{{- else if .Values.jaeger.enabled }} # use bundled config to connect to bundled jaeger
- "--config=/etc/otel-collector/configs/jaeger.yaml"
{{- else }} # use config defined by customer in values.yaml
- "--config=/etc/otel-collector/config.yaml"
{{- end }}
{{- end -}}
{{- with .Values.openTelemetry.gateway.args }}
args:
Expand Down
72 changes: 72 additions & 0 deletions charts/sourcegraph/tests/command_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
suite: command
release:
name: sourcegraph
namespace: sourcegraph
tests:
- it: should render no command for frontend and migrator by default
template: frontend/sourcegraph-frontend.Deployment.yaml
asserts:
- notExists:
path: spec.template.spec.containers[0].command
- notExists:
path: spec.template.spec.initContainers[0].command

- it: should render each item of a frontend command list as its own element
template: frontend/sourcegraph-frontend.Deployment.yaml
set:
frontend.command:
- sh
- -c
- |
export PGPASSWORD=$(cat /secrets/password);
/frontend serve
asserts:
- equal:
path: spec.template.spec.containers[0].command
value:
- sh
- -c
- |
export PGPASSWORD=$(cat /secrets/password);
/frontend serve
- notExists:
path: spec.template.spec.initContainers[0].command

- it: should render each item of a migrator command list as its own element
template: frontend/sourcegraph-frontend.Deployment.yaml
set:
migrator.command: ["sh", "-c", "/migrator up"]
asserts:
- equal:
path: spec.template.spec.initContainers[0].command
value: ["sh", "-c", "/migrator up"]
- notExists:
path: spec.template.spec.containers[0].command

- it: should still accept a command given as a string holding a YAML list
template: frontend/sourcegraph-frontend.Deployment.yaml
set:
frontend.command: '["sh", "-c", "/frontend serve"]'
migrator.command: '["sh", "-c", "/migrator up"]'
asserts:
- equal:
path: spec.template.spec.containers[0].command
value: ["sh", "-c", "/frontend serve"]
- equal:
path: spec.template.spec.initContainers[0].command
value: ["sh", "-c", "/migrator up"]

- it: should replace the otel-collector command, and keep args, when gateway.command is set
template: otel-collector/otel-collector.Deployment.yaml
set:
openTelemetry.gateway.command: ["/bin/sh", "-c"]
openTelemetry.gateway.args:
- API_KEY=$(cat /secrets/api-key) /bin/otelcol-sourcegraph --config=/etc/otel-collector/config.yaml
asserts:
- equal:
path: spec.template.spec.containers[0].command
value: ["/bin/sh", "-c"]
- equal:
path: spec.template.spec.containers[0].args
value:
- API_KEY=$(cat /secrets/api-key) /bin/otelcol-sourcegraph --config=/etc/otel-collector/config.yaml
12 changes: 12 additions & 0 deletions charts/sourcegraph/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ codeIntelDB:
storageAnnotations: {}

frontend:
# -- Command for the `frontend` container, as a list, replacing the image's entrypoint,
# e.g. a shell wrapper that exports credentials read from mounted files before starting `frontend`.
# `frontend.args` (default `["serve"]`) is still passed as the arguments.
command: []
# -- Environment variables for the `frontend` container
# @default -- the chart will add some default environment values
env:
Expand Down Expand Up @@ -411,6 +415,9 @@ migrator:
defaultTag: 8.1.4873@sha256:1683031a37687f672f4d40ba3508099e239881f9eab82e2faeed1e672ea4b60f
# -- Docker image name for the `migrator` image
name: "migrator"
# -- Command for the `migrator` init container, as a list, replacing the image's entrypoint.
# `migrator.args` (default `["up"]`) is still passed as the arguments.
command: []
# -- Environment variables for the `migrator` container
# @default -- the chart will add some default environment values
env:
Expand Down Expand Up @@ -723,6 +730,11 @@ openTelemetry:
gateway:
# -- Name used by resources. Does not affect service names or PVCs.
name: "otel-collector"
# -- Command for the `otel-collector` container, as a list, replacing the chart's
# `/bin/otelcol-sourcegraph --config=<file>` command, including the `--config` flag the chart
# selects, e.g. a shell wrapper that exports an exporter API key read from a mounted file.
# `openTelemetry.gateway.args` is still passed as the arguments.
command: []
# -- Resource requests & limits for the `otel-collector` container,
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
resources:
Expand Down
Loading