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). Continuity runs as a separate fleet next to `indexed-search`: a `indexed-searcher-indexer` Deployment builds index generations and publishes them through object storage, and a `indexed-searcher` StatefulSet and headless Service, configured under the new `indexedSearcher` values, download and serve them. Frontend, worker, searcher, and gitserver get the `SRC_INDEXED_SEARCH_CONTINUITY_*` settings. `indexedSearch.continuity.routing` (default `true`) sets `SRC_INDEXED_SEARCH_CONTINUITY_ROUTING`; existing instances set it to `false` first so searches stay on `indexed-search` while continuity indexes every repository, switch it to `true` once `src_zoekt_continuity_ready_to_route` is 1, then remove the old fleet with the new `indexedSearch.enabled: false` (default `true`) and delete its `data-indexed-search-*` PVCs. Prometheus scrapes the webservers and indexers on port `6060`. See [Indexed search continuity](README.md#indexed-search-continuity). 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
102 changes: 102 additions & 0 deletions charts/sourcegraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,68 @@ Helm only takes over an existing object that has the
and `meta.helm.sh/release-namespace` annotations, or when installing with
`--take-ownership` (Helm 3.17 or later).

## Indexed search continuity

Experimental: requires Sourcegraph images that include indexed search
continuity.

Indexed search continuity is a separate indexed search fleet. The
`indexed-searcher-indexer` Deployment builds index generations and publishes
them through object storage, and the `indexed-searcher` StatefulSet downloads
and serves them. It runs next to the `indexed-search` StatefulSet, with
different workload, Service, and PVC names, so an instance can switch over
without interrupting searches.

- `indexedSearch.continuity.enabled` renders the continuity fleet and sets
`SRC_INDEXED_SEARCH_CONTINUITY_*` on frontend, worker, searcher, gitserver,
and the continuity pods, which turns on continuity indexing.
- `indexedSearch.continuity.routing` (`SRC_INDEXED_SEARCH_CONTINUITY_ROUTING`)
chooses which fleet serves searches: `true` sends them to `indexed-searcher`,
`false` keeps them on `indexed-search`. Only frontend, worker, and searcher
get it, so switching it restarts only those.
- `indexedSearch.enabled` renders the `indexed-search` StatefulSet and its
Services, PodDisruptionBudget, and ServiceAccount.
- `indexedSearcher` configures the continuity webservers, and
`indexedSearch.continuity.indexer` the indexers.

### Migrating an existing instance

1. Enable continuity with routing off. The new fleet indexes every repository
from scratch and warms its webservers while searches still go to
`indexed-search`:

```yaml
indexedSearch:
continuity:
enabled: true
routing: false
```

2. Wait until the worker metric `src_zoekt_continuity_ready_to_route` is `1`:
every indexable repository has an active generation and every slot is ready
on all webservers of its placement.
3. Set `indexedSearch.continuity.routing: true` and upgrade. Searches now go to
`indexed-searcher`.
4. Set `indexedSearch.enabled: false` and upgrade to remove the
`indexed-search` StatefulSet. Kubernetes keeps a StatefulSet's PVCs after
the StatefulSet is deleted, so delete them to free their disks:

```sh
kubectl get pvc -o name | grep '^persistentvolumeclaim/data-indexed-search-' | xargs kubectl delete
```

### New installations

Instances without existing indexed search data can skip the migration:

```yaml
indexedSearch:
enabled: false
continuity:
enabled: true
routing: true
```

## Configuration Options

Reference the below chart for all available configuration parameters.
Expand Down Expand Up @@ -264,6 +326,24 @@ 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 continuity next to `indexed-search`: the `indexed-searcher-indexer` Deployment builds index generations and publishes them through object storage, and the `indexed-searcher` StatefulSet (configured under `indexedSearcher`) downloads and serves them. Frontend, worker, searcher, and gitserver get the `SRC_INDEXED_SEARCH_CONTINUITY_*` settings. See [Indexed search continuity](#indexed-search-continuity). |
| indexedSearch.continuity.env | object | `{}` | Extra environment variables for every continuity participant (webserver, indexer, frontend, worker, searcher, gitserver), 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 `zoekt-continuity-indexer` container |
| indexedSearch.continuity.indexer.name | string | `"indexed-searcher-indexer"` | Name of the indexer Deployment and its metrics Service |
| indexedSearch.continuity.indexer.replicaCount | int | `2` | Number of `indexed-searcher-indexer` pods |
| indexedSearch.continuity.indexer.resources | object | `{"limits":{"cpu":"4","memory":"4G"},"requests":{"cpu":"1","memory":"1G"}}` | Resource requests & limits for the `zoekt-continuity-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_WARM_REPLICAS`). Must not exceed `indexedSearcher.replicaCount`. |
| 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.routing | bool | `true` | Send searches to the continuity webservers (`SRC_INDEXED_SEARCH_CONTINUITY_ROUTING`). When `false`, continuity indexes every repository and warms its webservers while searches keep using `indexed-search`. Instances migrating from `indexed-search` set it to `false` first and to `true` once the worker metric `src_zoekt_continuity_ready_to_route` is 1. |
| indexedSearch.enabled | bool | `true` | Enable the `indexed-search` StatefulSet (`zoekt-webserver` and `zoekt-indexserver`) and its Services, PodDisruptionBudget, and ServiceAccount. Set to `false` to remove it after searches have switched to indexed search continuity, see [Indexed search continuity](#indexed-search-continuity). |
| 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 All @@ -285,6 +365,28 @@ In addition to the documented values, all services also support the following va
| indexedSearchIndexer.image.defaultTag | string | `<appVersion>@sha256:<digest>`, pinned by each release | Docker image tag for the `zoekt-indexserver` image |
| indexedSearchIndexer.image.name | string | `"search-indexer"` | Docker image name for the `zoekt-indexserver` image |
| indexedSearchIndexer.resources | object | `{"limits":{"cpu":"8","memory":"8G"},"requests":{"cpu":"4","memory":"4G"}}` | Resource requests & limits for the `zoekt-indexserver` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) zoekt-indexserver is CPU bound. The more CPU you allocate to it, the lower lag between a new commit and it being indexed for search. |
| indexedSearcher.args | list | `[]` | Arguments for the `zoekt-continuity-webserver` container |
| indexedSearcher.command | list | `[]` | Command for the `zoekt-continuity-webserver` container, replacing the image's entrypoint |
| indexedSearcher.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `zoekt-continuity-webserver` and `zoekt-continuity-indexer` containers, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
| indexedSearcher.env | object | `{"DEPLOY_TYPE":{"value":"helm"}}` | Environment variables for the `zoekt-continuity-webserver` container |
| indexedSearcher.image.name | string | `"zoekt-continuity-webserver"` | Docker image name for the `zoekt-continuity-webserver` image. The tag defaults to the chart's appVersion. |
| indexedSearcher.image.repository | string | `""` | Override the global sourcegraph.image.repository for the `zoekt-continuity-webserver` image |
| indexedSearcher.image.tag | string | `""` | Override the tag of the `zoekt-continuity-webserver` image |
| indexedSearcher.livenessProbe | object | `{"failureThreshold":10,"initialDelaySeconds":120,"periodSeconds":60,"timeoutSeconds":5}` | Liveness probe tuning for the `zoekt-continuity-webserver` container (`/healthz` on port 6070) |
| indexedSearcher.name | string | `"indexed-searcher"` | Name used by the `indexed-searcher` StatefulSet, PodDisruptionBudget, and ServiceAccount. Does not affect service names or PVCs. The frontend finds the webservers through the StatefulSet named `indexed-searcher` (`k8s+rpc://indexed-searcher:6070?kind=sts`), so if you change it, also list the webservers in `SRC_INDEXED_SEARCH_CONTINUITY_WEBSERVERS` in `frontend.env`. |
| indexedSearcher.podDisruptionBudget | object | `{}` | Pod disruption budget for `indexed-searcher`. Configure either `minAvailable` or `maxUnavailable` to enable it. |
| indexedSearcher.podSecurityContext | object | `{"fsGroup":101,"fsGroupChangePolicy":"OnRootMismatch"}` | Security context for the `indexed-searcher` and `indexed-searcher-indexer` pods, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod) |
| indexedSearcher.readinessProbe | object | `{"failureThreshold":3,"periodSeconds":5,"timeoutSeconds":5}` | Readiness probe tuning for the `zoekt-continuity-webserver` container (`/ready` on port 6070) |
| indexedSearcher.replicaCount | int | `2` | Number of `indexed-searcher` pods. Rendered only when `indexedSearch.continuity.enabled` is `true`. |
| indexedSearcher.resources | object | `{"limits":{"cpu":"2","memory":"4G"},"requests":{"cpu":"500m","memory":"2G"}}` | Resource requests & limits for the `zoekt-continuity-webserver` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| indexedSearcher.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `indexed-searcher` and `indexed-searcher-indexer` |
| indexedSearcher.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
| indexedSearcher.storageAnnotations | object | `{}` | Optional annotations to add to the `indexed-searcher` PVC |
| indexedSearcher.storageClassName | string | `""` | Storage class of the `indexed-searcher` data volume. Defaults to `storageClass.name`. |
| indexedSearcher.storageLabels | object | `{}` | Labels to add to the `data` volume claim template of the `indexed-searcher` StatefulSet. Kubernetes does not allow changing them on an installed StatefulSet. |
| indexedSearcher.storageSize | string | `"200Gi"` | PVC Storage Request for the `indexed-searcher` data volume, which caches the generations a webserver serves |
| indexedSearcher.storageSubPath | string | `""` | Optional subPath for the `indexed-searcher` primary data volume mount |
| indexedSearcher.terminationGracePeriodSeconds | int | `60` | Time Kubernetes allows a continuity webserver to drain before forced termination. Must be at least 30. |
| jaeger.args | list | `["--config=/etc/jaeger/jaeger-config.yaml"]` | Default args passed to the `jaeger` binary. Jaeger v2.16+ uses a YAML config file instead of CLI flags. See https://www.jaegertracing.io/docs/2.16/configuration/ |
| jaeger.collector.name | string | `""` | Name of jaeger `collector` service |
| jaeger.collector.serviceAnnotations | object | `{}` | Add extra annotations to jaeger `collector` service |
Expand Down
62 changes: 62 additions & 0 deletions charts/sourcegraph/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,68 @@ Helm only takes over an existing object that has the
and `meta.helm.sh/release-namespace` annotations, or when installing with
`--take-ownership` (Helm 3.17 or later).

## Indexed search continuity

Experimental: requires Sourcegraph images that include indexed search
continuity.

Indexed search continuity is a separate indexed search fleet. The
`indexed-searcher-indexer` Deployment builds index generations and publishes
them through object storage, and the `indexed-searcher` StatefulSet downloads
and serves them. It runs next to the `indexed-search` StatefulSet, with
different workload, Service, and PVC names, so an instance can switch over
without interrupting searches.

- `indexedSearch.continuity.enabled` renders the continuity fleet and sets
`SRC_INDEXED_SEARCH_CONTINUITY_*` on frontend, worker, searcher, gitserver,
and the continuity pods, which turns on continuity indexing.
- `indexedSearch.continuity.routing` (`SRC_INDEXED_SEARCH_CONTINUITY_ROUTING`)
chooses which fleet serves searches: `true` sends them to `indexed-searcher`,
`false` keeps them on `indexed-search`. Only frontend, worker, and searcher
get it, so switching it restarts only those.
- `indexedSearch.enabled` renders the `indexed-search` StatefulSet and its
Services, PodDisruptionBudget, and ServiceAccount.
- `indexedSearcher` configures the continuity webservers, and
`indexedSearch.continuity.indexer` the indexers.

### Migrating an existing instance

1. Enable continuity with routing off. The new fleet indexes every repository
from scratch and warms its webservers while searches still go to
`indexed-search`:

```yaml
indexedSearch:
continuity:
enabled: true
routing: false
```

2. Wait until the worker metric `src_zoekt_continuity_ready_to_route` is `1`:
every indexable repository has an active generation and every slot is ready
on all webservers of its placement.
3. Set `indexedSearch.continuity.routing: true` and upgrade. Searches now go to
`indexed-searcher`.
4. Set `indexedSearch.enabled: false` and upgrade to remove the
`indexed-search` StatefulSet. Kubernetes keeps a StatefulSet's PVCs after
the StatefulSet is deleted, so delete them to free their disks:

```sh
kubectl get pvc -o name | grep '^persistentvolumeclaim/data-indexed-search-' | xargs kubectl delete
```

### New installations

Instances without existing indexed search data can skip the migration:

```yaml
indexedSearch:
enabled: false
continuity:
enabled: true
routing: true
```

## Configuration Options

Reference the below chart for all available configuration parameters.
Expand Down
Loading
Loading