Skip to content
Draft
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

- Added opt-in indexed search continuity behind `indexedSearch.continuity.enabled` (default `false`, which renders the same manifests as before). When enabled, the `indexed-search` StatefulSet runs one `zoekt-continuity-webserver` container per pod instead of `zoekt-webserver` and `zoekt-indexserver`, a new `indexed-search-indexer` Deployment builds shards and publishes them through object storage, and frontend, worker, searcher, and gitserver get the `SRC_INDEXED_SEARCH_CONTINUITY_*` settings. Prometheus scrapes the webservers and indexers on port `6060`. Set `indexedSearch.continuity.replicas`, `activationTolerance`, and `replicationFactors` to control how many webservers hold each repository, and `indexedSearch.continuity.indexer.env` for indexer settings such as `SRC_INDEXED_SEARCH_CONTINUITY_DELTA_REPOS`. Experimental: requires Sourcegraph images that include continuity.
- 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 `sourcegraph.selectorLabelsOverride`, `<serviceName>.extraSelectorLabels`, and `storageLabels` on `gitserver`, `grafana`, `indexedSearch`, and `searcher`, so the chart can render the selectors and volume claim templates of workloads created outside it, such as with Kustomize, and a Helm release can take them over without deleting them. All default to empty, so existing releases render the same selectors. Never change them on an installed release: Kubernetes does not allow changing these fields. See [Adopting existing workloads](README.md#adopting-existing-workloads).
- 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.
Expand Down
23 changes: 23 additions & 0 deletions charts/sourcegraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,29 @@ In addition to the documented values, all services also support the following va
| grafana.storageSize | string | `"2Gi"` | PVC Storage Request for `grafana` data volume |
| grafana.storageSubPath | string | `""` | Optional subPath for the `grafana` primary data volume mount |
| indexedSearch.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `zoekt-webserver` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
| indexedSearch.continuity.activationTolerance | int | `1` | Number of a repository's replicas that may lag when a new generation activates: activation needs the replicas the repository can have now minus this many, and at least one (`SRC_INDEXED_SEARCH_CONTINUITY_ACTIVATION_TOLERANCE`) |
| indexedSearch.continuity.enabled | bool | `false` | Run indexed search in continuity mode: `indexed-search` pods run only the continuity webserver (no `zoekt-indexserver` container), a separate `indexed-search-indexer` Deployment builds shards and publishes them through object storage, and frontend, worker, and searcher use the continuity search client. |
| indexedSearch.continuity.env | object | `{}` | Extra environment variables for every continuity participant (webserver, indexer, frontend, worker, searcher), for example `SOURCEGRAPH_UPLOAD_*` object storage settings. By default the shared Sourcegraph object storage settings apply, which use the `blobstore` service. |
| indexedSearch.continuity.indexer.args | list | `[]` | Arguments for the indexer container |
| indexedSearch.continuity.indexer.command | list | `[]` | Command for the indexer container, replacing the image's entrypoint |
| indexedSearch.continuity.indexer.env | object | `{"DEPLOY_TYPE":{"value":"helm"}}` | Environment variables for the `indexed-search-indexer` container |
| indexedSearch.continuity.indexer.name | string | `"indexed-search-indexer"` | Name used by the indexer Deployment |
| indexedSearch.continuity.indexer.replicaCount | int | `2` | Number of `indexed-search-indexer` pods |
| indexedSearch.continuity.indexer.resources | object | `{"limits":{"cpu":"4","memory":"4G"},"requests":{"cpu":"1","memory":"1G"}}` | Resource requests & limits for the `indexed-search-indexer` container |
| indexedSearch.continuity.indexer.scratchSizeLimit | string | `"20Gi"` | Size limit of the indexer's emptyDir scratch volume |
| indexedSearch.continuity.indexerImage.defaultTag | string | `"{{ .Chart.AppVersion }}"` | Docker image tag for the continuity indexer image |
| indexedSearch.continuity.indexerImage.name | string | `"zoekt-continuity-indexer"` | Docker image name for the continuity indexer image |
| indexedSearch.continuity.indexerImage.repository | string | `""` | Override the global sourcegraph.image.repository for the continuity indexer image |
| indexedSearch.continuity.indexerImage.tag | string | `""` | Override the tag of the continuity indexer image |
| indexedSearch.continuity.replicas | int | `2` | Number of webserver replicas that hold each slot (`SRC_INDEXED_SEARCH_CONTINUITY_REPLICAS`) |
| indexedSearch.continuity.replicationFactors | string | `""` | Comma-separated `repositoryID=replicas` entries that raise the replicas of individual repositories, such as large monorepos, and with them their slot (`SRC_INDEXED_SEARCH_CONTINUITY_REPLICATION_FACTORS`) |
| indexedSearch.continuity.terminationGracePeriodSeconds | int | `60` | Time Kubernetes allows a continuity webserver to drain before forced termination. Must be at least 30. |
| indexedSearch.continuity.webserverArgs | list | `[]` | Arguments for the continuity webserver container |
| indexedSearch.continuity.webserverCommand | list | `[]` | Command for the continuity webserver container, replacing the image's entrypoint |
| indexedSearch.continuity.webserverImage.defaultTag | string | `"{{ .Chart.AppVersion }}"` | Docker image tag for the continuity webserver image |
| indexedSearch.continuity.webserverImage.name | string | `"zoekt-continuity-webserver"` | Docker image name for the continuity webserver image |
| indexedSearch.continuity.webserverImage.repository | string | `""` | Override the global sourcegraph.image.repository for the continuity webserver image |
| indexedSearch.continuity.webserverImage.tag | string | `""` | Override the tag of the continuity webserver image |
| indexedSearch.env | object | the chart will add some default environment values | Environment variables for the `zoekt-webserver` container |
| indexedSearch.image.defaultTag | string | `<appVersion>@sha256:<digest>`, pinned by each release | Docker image tag for the `zoekt-webserver` image |
| indexedSearch.image.name | string | `"indexed-searcher"` | Docker image name for the `zoekt-webserver` image |
Expand Down
58 changes: 58 additions & 0 deletions charts/sourcegraph/templates/_helpers/_indexedSearchContinuity.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{/*
Render the image reference for an indexed search continuity image.
Usage: include "sourcegraph.indexedSearchContinuity.image" (list . .Values.indexedSearch.continuity.webserverImage)
*/}}
{{- define "sourcegraph.indexedSearchContinuity.image" -}}
{{- $top := index . 0 -}}
{{- $image := index . 1 -}}
{{- $repository := default $top.Values.sourcegraph.image.repository $image.repository -}}
{{- $defaultTag := tpl (toString $image.defaultTag) $top -}}
{{- if $top.Values.sourcegraph.image.useGlobalTagAsDefault }}{{ $defaultTag = (tpl $top.Values.sourcegraph.image.defaultTag $top) }}{{ end -}}
{{- $repository }}/{{ $image.name }}:{{ default $defaultTag $image.tag }}
{{- end }}

{{/*
Render the environment variables that every indexed search continuity participant
(webserver, indexer, frontend, worker, searcher) must share. Renders nothing when
continuity is disabled.
*/}}
{{- define "sourcegraph.indexedSearchContinuity.env" -}}
{{- $continuity := .Values.indexedSearch.continuity -}}
{{- if $continuity.enabled -}}
- name: SRC_INDEXED_SEARCH_CONTINUITY_ENABLED
value: "true"
- name: SRC_INDEXED_SEARCH_CONTINUITY_REPLICAS
value: {{ $continuity.replicas | quote }}
- name: SRC_INDEXED_SEARCH_CONTINUITY_ACTIVATION_TOLERANCE
value: {{ $continuity.activationTolerance | quote }}
{{- with $continuity.replicationFactors }}
- name: SRC_INDEXED_SEARCH_CONTINUITY_REPLICATION_FACTORS
value: {{ . | quote }}
{{- end }}
{{- range $name, $item := $continuity.env }}
- name: {{ $name }}
{{- $item | toYaml | nindent 2 }}
{{- end }}
{{- end -}}
{{- end }}

{{/*
Fail rendering when the continuity values are inconsistent.
*/}}
{{- define "sourcegraph.indexedSearchContinuity.validate" -}}
{{- $continuity := .Values.indexedSearch.continuity -}}
{{- if $continuity.enabled -}}
{{- if lt (int $continuity.terminationGracePeriodSeconds) 30 -}}
{{- fail "indexedSearch.continuity.terminationGracePeriodSeconds must be at least 30" -}}
{{- end -}}
{{- if gt (int $continuity.replicas) (int .Values.indexedSearch.replicaCount) -}}
{{- fail "indexedSearch.continuity.replicas must not exceed indexedSearch.replicaCount" -}}
{{- end -}}
{{- if lt (int $continuity.activationTolerance) 0 -}}
{{- fail "indexedSearch.continuity.activationTolerance must not be negative" -}}
{{- end -}}
{{- if and (gt (int $continuity.replicas) 1) (ge (int $continuity.activationTolerance) (int $continuity.replicas)) -}}
{{- fail "indexedSearch.continuity.activationTolerance must be less than indexedSearch.continuity.replicas" -}}
{{- end -}}
{{- end -}}
{{- end }}
1 change: 1 addition & 0 deletions charts/sourcegraph/templates/_worker.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ spec:
fieldRef:
fieldPath: metadata.name
{{- include "sourcegraph.openTelemetryEnv" $top | nindent 8 }}
{{- with include "sourcegraph.indexedSearchContinuity.env" $top }}{{ . | nindent 8 }}{{- end }}
image: {{ include "sourcegraph.image" (list $top "worker" ) }}
imagePullPolicy: {{ $top.Values.sourcegraph.image.pullPolicy }}
{{- with $top.Values.worker.args }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ spec:
{{- end }}
{{- include "sourcegraph.redisConnection" .| nindent 8 }}
{{- include "sourcegraph.openTelemetryEnv" . | nindent 8 }}
{{- with include "sourcegraph.indexedSearchContinuity.env" . }}{{ . | nindent 8 }}{{- end }}
terminationMessagePolicy: FallbackToLogsOnError
livenessProbe:
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ spec:
env:
{{- include "sourcegraph.gracefulShutdownEnv" (list . "gitserver") | nindent 8 }}
{{- include "sourcegraph.redisConnection" .| nindent 8 }}
{{- with include "sourcegraph.indexedSearchContinuity.env" . }}{{ . | 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
@@ -0,0 +1,114 @@
{{- if .Values.indexedSearch.continuity.enabled -}}
{{- $indexer := .Values.indexedSearch.continuity.indexer -}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
description: Builds indexed search shards and publishes them through object storage for continuity webservers.
labels:
{{- include "sourcegraph.labels" . | nindent 4 }}
{{- if .Values.indexedSearch.labels }}
{{- toYaml .Values.indexedSearch.labels | nindent 4 }}
{{- end }}
deploy: sourcegraph
app.kubernetes.io/component: indexed-search-indexer
name: {{ $indexer.name }}
spec:
replicas: {{ $indexer.replicaCount }}
revisionHistoryLimit: {{ .Values.sourcegraph.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "sourcegraph.selectorLabels" (list . .Values.indexedSearch) | nindent 6 }}
app: indexed-search-indexer
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: zoekt-continuity-indexer
{{- if .Values.sourcegraph.podAnnotations }}
{{- toYaml .Values.sourcegraph.podAnnotations | nindent 8 }}
{{- end }}
{{- if .Values.indexedSearch.podAnnotations }}
{{- toYaml .Values.indexedSearch.podAnnotations | nindent 8 }}
{{- end }}
labels:
{{- include "sourcegraph.selectorLabels" (list . .Values.indexedSearch) | nindent 8 }}
{{- if .Values.sourcegraph.podLabels }}
{{- toYaml .Values.sourcegraph.podLabels | nindent 8 }}
{{- end }}
app: indexed-search-indexer
deploy: sourcegraph
spec:
{{- include "sourcegraph.terminationGracePeriodSeconds" (list . "indexedSearch") | nindent 6 }}
containers:
- name: zoekt-continuity-indexer
image: {{ include "sourcegraph.indexedSearchContinuity.image" (list . .Values.indexedSearch.continuity.indexerImage) }}
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
{{- with $indexer.command }}
command:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $indexer.args }}
args:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationMessagePolicy: FallbackToLogsOnError
env:
{{- range $name, $item := $indexer.env }}
- name: {{ $name }}
{{- $item | toYaml | nindent 10 }}
{{- end }}
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: DATA_DIR
value: /data
- name: TMPDIR
value: /data
- name: HOME
value: /data
- name: SRC_FRONTEND_INTERNAL
value: sourcegraph-frontend-internal
{{- if not .Values.sourcegraph.disableKubernetesSecrets }}
{{- include "sourcegraph.databaseAuth" (list . "pgsql" "PG") | nindent 8 }}
{{- end }}
{{- include "sourcegraph.redisConnection" . | nindent 8 }}
{{- include "sourcegraph.indexedSearchContinuity.env" . | nindent 8 }}
{{- include "sourcegraph.openTelemetryEnv" . | nindent 8 }}
{{- if .Values.openTelemetry.enabled }}
- name: OPENTELEMETRY_DISABLED
value: "false"
{{- end }}
ports:
- name: http-debug
containerPort: 6060
{{- if not .Values.sourcegraph.localDevMode }}
resources:
{{- toYaml $indexer.resources | nindent 10 }}
{{- end }}
securityContext:
{{- toYaml .Values.indexedSearchIndexer.containerSecurityContext | nindent 10 }}
volumeMounts:
- mountPath: /data
name: scratch
securityContext:
{{- toYaml .Values.indexedSearch.podSecurityContext | nindent 8 }}
{{- include "sourcegraph.nodeSelector" (list . "indexedSearch" ) | trim | nindent 6 }}
{{- include "sourcegraph.affinity" (list . "indexedSearch" ) | trim | nindent 6 }}
{{- with include "sourcegraph.priorityClassName" (list . "indexedSearch" ) | trim }}{{ . | nindent 6 }}{{- end }}
{{- include "sourcegraph.tolerations" (list . "indexedSearch" ) | trim | nindent 6 }}
{{- with .Values.sourcegraph.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "sourcegraph.renderServiceAccountName" (list . "indexedSearch") | trim | nindent 6 }}
volumes:
- name: scratch
emptyDir:
sizeLimit: {{ $indexer.scratchSizeLimit }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.indexedSearch.continuity.enabled -}}
{{- $indexer := .Values.indexedSearch.continuity.indexer -}}
apiVersion: v1
kind: Service
metadata:
annotations:
description: Exposes the indexed search continuity indexers' metrics to Prometheus.
prometheus.io/port: "6060"
sourcegraph.prometheus/scrape: "true"
labels:
app: {{ $indexer.name }}
deploy: sourcegraph
app.kubernetes.io/component: indexed-search-indexer
name: {{ $indexer.name }}
spec:
clusterIP: None
ports:
- name: http-debug
port: 6060
targetPort: http-debug
selector:
{{- include "sourcegraph.selectorLabels" (list . .Values.indexedSearch) | nindent 4 }}
app: indexed-search-indexer
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.indexedSearch.continuity.enabled -}}
apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -27,3 +28,4 @@ spec:
{{- include "sourcegraph.selectorLabels" (list . .Values.indexedSearch) | nindent 4 }}
app: indexed-search
type: {{ .Values.indexedSearch.serviceType | default "ClusterIP" }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ metadata:
annotations:
description: Headless service that provides a stable network identity for the
indexed-search stateful set.
{{- if .Values.indexedSearch.continuity.enabled }}
# Continuity webservers serve metrics on their debug port.
prometheus.io/port: "6060"
{{- else }}
prometheus.io/port: "6070"
{{- end }}
sourcegraph.prometheus/scrape: "true"
{{- if .Values.indexedSearch.serviceAnnotations }}
{{- toYaml .Values.indexedSearch.serviceAnnotations | nindent 4 }}
Expand Down
Loading
Loading