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 the opt-in Zoekt indexer and searchers behind `zoekt.enabled` (default `false`, which renders the same manifests as before). They run as a separate fleet next to `indexed-search`: a `zoekt-indexer` Deployment builds index generations and publishes them through object storage, and a `zoekt-searcher` StatefulSet and headless Service, configured under the new `zoektSearcher` values, download and serve them. Frontend, worker, and searcher get the `SRC_ZOEKT_*` settings. `zoekt.routing` (default `true`) sets `SRC_ZOEKT_SEARCHER_ROUTING`; existing instances set it to `false` first so searches stay on `indexed-search` while the Zoekt indexer indexes every repository, switch it to `true` once `src_zoekt_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 searchers and indexers on port `6060`. See [Zoekt indexer and searchers](README.md#zoekt-indexer-and-searchers). Experimental: requires Sourcegraph images that include the Zoekt indexer and searchers.
- 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
105 changes: 104 additions & 1 deletion 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).

## Zoekt indexer and searchers

Experimental: requires Sourcegraph images that include the Zoekt indexer and
searchers.

The Zoekt indexer and searchers are a separate indexed search fleet. The
`zoekt-indexer` Deployment builds index generations and publishes
them through object storage, and the `zoekt-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.

- `zoekt.enabled` renders the new fleet and sets `SRC_ZOEKT_*` on frontend,
worker, searcher, and the new pods, which turns on Zoekt indexing.
- `zoekt.routing` (`SRC_ZOEKT_SEARCHER_ROUTING`)
chooses which fleet serves searches: `true` sends them to `zoekt-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. When it is `false`, the
frontend gets empty `INDEXED_SEARCH_SERVERS` and `INDEXED_SEARCH_INDEXER`, so
it stops looking for the removed StatefulSet, unless `frontend.env` sets them.
- `zoektSearcher` configures the Zoekt searchers, and
`zoekt.indexer` the indexers.

### Migrating an existing instance

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

```yaml
zoekt:
enabled: true
routing: false
```

2. Wait until the worker metric `src_zoekt_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 `zoekt.routing: true` and upgrade. Searches now go to
`zoekt-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
zoekt:
enabled: true
routing: true
```

## Configuration Options

Reference the below chart for all available configuration parameters.
Expand Down Expand Up @@ -264,9 +326,10 @@ 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.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 the Zoekt indexer and searchers, see [Zoekt indexer and searchers](#zoekt-indexer-and-searchers). |
| 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 |
| indexedSearch.image.name | string | `"zoekt-searcher"` | Docker image name for the `zoekt-webserver` image |
| indexedSearch.livenessProbe | object | `{"failureThreshold":10,"initialDelaySeconds":120,"periodSeconds":60,"timeoutSeconds":5}` | Liveness probe tuning for the `zoekt-webserver` container. Raise `failureThreshold` or `timeoutSeconds` where memory pressure stalls `/healthz` for minutes at a time, so the container is not killed while it is still serving. Keep the window wider than zoekt's in-process watchdog (`ZOEKT_WATCHDOG_ERRORS` x `ZOEKT_WATCHDOG_TICK`) so the watchdog stays the first line of defence. |
| indexedSearch.name | string | `"indexed-search"` | Name used by resources. Does not affect service names or PVCs. |
| indexedSearch.podDisruptionBudget | object | `{}` | Pod disruption budget for `indexed-search`. Configure either `minAvailable` or `maxUnavailable` to enable it. |
Expand Down Expand Up @@ -538,3 +601,43 @@ In addition to the documented values, all services also support the following va
| worker.resources | object | `{"limits":{"cpu":"2","memory":"4G"},"requests":{"cpu":"500m","memory":"2G"}}` | Resource requests & limits for the `worker` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| worker.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `worker` |
| worker.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
| zoekt.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_ZOEKT_ACTIVATION_TOLERANCE`) |
| zoekt.enabled | bool | `false` | Run the Zoekt indexer and searchers next to `indexed-search`: the `zoekt-indexer` Deployment builds index generations and publishes them through object storage, and the `zoekt-searcher` StatefulSet (configured under `zoektSearcher`) downloads and serves them. Frontend, worker, and searcher get the `SRC_ZOEKT_*` settings. See [Zoekt indexer and searchers](#zoekt-indexer-and-searchers). |
| zoekt.env | object | `{}` | Extra environment variables for the Zoekt searchers and indexers and for frontend, worker, and searcher, for example `SOURCEGRAPH_UPLOAD_*` object storage settings. By default the shared Sourcegraph object storage settings apply, which use the `blobstore` service. |
| zoekt.indexer.args | list | `[]` | Arguments for the indexer container |
| zoekt.indexer.command | list | `[]` | Command for the indexer container, replacing the image's entrypoint |
| zoekt.indexer.env | object | `{"DEPLOY_TYPE":{"value":"helm"}}` | Environment variables for the `zoekt-indexer` container |
| zoekt.indexer.name | string | `"zoekt-indexer"` | Name of the indexer Deployment and its metrics Service |
| zoekt.indexer.replicaCount | int | `2` | Number of `zoekt-indexer` pods |
| zoekt.indexer.resources | object | `{"limits":{"cpu":"4","memory":"4G"},"requests":{"cpu":"1","memory":"1G"}}` | Resource requests & limits for the `zoekt-indexer` container |
| zoekt.indexer.scratch.persistentVolume | bool | `true` | Back each indexer pod's scratch directory, where it fetches repositories and builds shards, with its own PersistentVolumeClaim (a generic ephemeral volume). Kubernetes deletes the claim, and with a `Delete` reclaim policy its disk, when the pod goes away, such as on scale-down or a rollout. Set to `false` to use an `emptyDir` on the node's disk instead, with a matching `ephemeral-storage` request |
| zoekt.indexer.scratch.size | string | `"100Gi"` | Size of the scratch volume: the claim's storage request, or the `emptyDir` size limit and `ephemeral-storage` request. Large monorepos need room for a fetch and its shards per concurrent job |
| zoekt.indexer.scratch.storageClassName | string | `""` | Storage class of the scratch volume's claim. Its reclaim policy should be `Delete`, so disks go away with their pods. Defaults to `<storageClass.name>-scratch`, which the chart creates like `storageClass` but with the `Delete` reclaim policy, or to the cluster's default storage class if `storageClass.create` is false |
| zoekt.indexerImage.defaultTag | string | `"{{ .Chart.AppVersion }}"` | Docker image tag for the Zoekt indexer image |
| zoekt.indexerImage.name | string | `"zoekt-indexer"` | Docker image name for the Zoekt indexer image |
| zoekt.indexerImage.repository | string | `""` | Override the global sourcegraph.image.repository for the Zoekt indexer image |
| zoekt.indexerImage.tag | string | `""` | Override the tag of the Zoekt indexer image |
| zoekt.replicas | int | `2` | Number of webserver replicas that hold each slot (`SRC_ZOEKT_WARM_REPLICAS`). Must not exceed `zoektSearcher.replicaCount`. |
| zoekt.replicationFactors | string | `""` | Comma-separated `repositoryID=replicas` entries that raise the replicas of individual repositories, such as large monorepos, and with them their slot (`SRC_ZOEKT_REPLICATION_FACTORS`) |
| zoekt.routing | bool | `true` | Send searches to the Zoekt searchers (`SRC_ZOEKT_SEARCHER_ROUTING`). When `false`, the Zoekt indexer indexes every repository and warms the searchers 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_ready_to_route` is 1. |
| zoektSearcher.args | list | `[]` | Arguments for the `zoekt-searcher` container |
| zoektSearcher.command | list | `[]` | Command for the `zoekt-searcher` container, replacing the image's entrypoint |
| zoektSearcher.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `zoekt-searcher` and `zoekt-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) |
| zoektSearcher.env | object | `{"DEPLOY_TYPE":{"value":"helm"}}` | Environment variables for the `zoekt-searcher` container |
| zoektSearcher.image.name | string | `"zoekt-searcher"` | Docker image name for the `zoekt-searcher` image. The tag defaults to the chart's appVersion. |
| zoektSearcher.image.repository | string | `""` | Override the global sourcegraph.image.repository for the `zoekt-searcher` image |
| zoektSearcher.image.tag | string | `""` | Override the tag of the `zoekt-searcher` image |
| zoektSearcher.livenessProbe | object | `{"failureThreshold":10,"initialDelaySeconds":120,"periodSeconds":60,"timeoutSeconds":5}` | Liveness probe tuning for the `zoekt-searcher` container (`/healthz` on port 6070) |
| zoektSearcher.name | string | `"zoekt-searcher"` | Name used by the `zoekt-searcher` StatefulSet, PodDisruptionBudget, and ServiceAccount. Does not affect service names or PVCs. The frontend finds the webservers through the StatefulSet named `zoekt-searcher` (`k8s+rpc://zoekt-searcher:6070?kind=sts`), so if you change it, also list the webservers in `SRC_ZOEKT_SEARCHERS` in `frontend.env`. |
| zoektSearcher.podDisruptionBudget | object | `{}` | Pod disruption budget for `zoekt-searcher`. Configure either `minAvailable` or `maxUnavailable` to enable it. |
| zoektSearcher.podSecurityContext | object | `{"fsGroup":101,"fsGroupChangePolicy":"OnRootMismatch"}` | Security context for the `zoekt-searcher` and `zoekt-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) |
| zoektSearcher.readinessProbe | object | `{"failureThreshold":3,"periodSeconds":5,"timeoutSeconds":5}` | Readiness probe tuning for the `zoekt-searcher` container (`/ready` on port 6070) |
| zoektSearcher.replicaCount | int | `2` | Number of `zoekt-searcher` pods. Rendered only when `zoekt.enabled` is `true`. |
| zoektSearcher.resources | object | `{"limits":{"cpu":"2","memory":"4G"},"requests":{"cpu":"500m","memory":"2G"}}` | Resource requests & limits for the `zoekt-searcher` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| zoektSearcher.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `zoekt-searcher` and `zoekt-indexer` |
| zoektSearcher.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
| zoektSearcher.storageAnnotations | object | `{}` | Optional annotations to add to the `zoekt-searcher` PVC |
| zoektSearcher.storageClassName | string | `""` | Storage class of the `zoekt-searcher` data volume. Defaults to `storageClass.name`. |
| zoektSearcher.storageLabels | object | `{}` | Labels to add to the `data` volume claim template of the `zoekt-searcher` StatefulSet. Kubernetes does not allow changing them on an installed StatefulSet. |
| zoektSearcher.storageSize | string | `"200Gi"` | PVC Storage Request for the `zoekt-searcher` data volume, which caches the generations a webserver serves |
| zoektSearcher.storageSubPath | string | `""` | Optional subPath for the `zoekt-searcher` primary data volume mount |
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).

## Zoekt indexer and searchers

Experimental: requires Sourcegraph images that include the Zoekt indexer and
searchers.

The Zoekt indexer and searchers are a separate indexed search fleet. The
`zoekt-indexer` Deployment builds index generations and publishes
them through object storage, and the `zoekt-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.

- `zoekt.enabled` renders the new fleet and sets `SRC_ZOEKT_*` on frontend,
worker, searcher, and the new pods, which turns on Zoekt indexing.
- `zoekt.routing` (`SRC_ZOEKT_SEARCHER_ROUTING`)
chooses which fleet serves searches: `true` sends them to `zoekt-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. When it is `false`, the
frontend gets empty `INDEXED_SEARCH_SERVERS` and `INDEXED_SEARCH_INDEXER`, so
it stops looking for the removed StatefulSet, unless `frontend.env` sets them.
- `zoektSearcher` configures the Zoekt searchers, and
`zoekt.indexer` the indexers.

### Migrating an existing instance

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

```yaml
zoekt:
enabled: true
routing: false
```

2. Wait until the worker metric `src_zoekt_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 `zoekt.routing: true` and upgrade. Searches now go to
`zoekt-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
zoekt:
enabled: true
routing: true
```

## Configuration Options

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