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
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 experimental `zoekt-indexer` Deployment and `zoekt-searcher` StatefulSet behind `zoektIndexer.enabled` and `zoektSearcher.enabled` (both default `false`, which renders the same manifests as before). The indexer builds index generations and publishes them through object storage, and the searchers download and serve them, next to `indexed-search`. The chart does not configure the Zoekt indexer itself: it stays off until `SRC_ZOEKT_INDEXER_ENABLED` is set in the services' `env`. Added `indexedSearch.enabled` (default `true`) to remove the `indexed-search` objects; the frontend then stops discovering them. Prometheus scrapes the searchers and indexers on port `6060`. See [Zoekt indexer and searchers](README.md#zoekt-indexer-and-searchers). Requires Sourcegraph images that include the Zoekt indexer and searchers.
- `sourcegraph.labels` and `<serviceName>.labels` are now also rendered on each component's ConfigMaps, Secrets, standalone PersistentVolumeClaims, ServiceAccounts, RBAC objects, PodDisruptionBudgets, and Ingress, not only on its workload, and `sourcegraph.serviceLabels`, documented but not used before, on every Service. Nothing changes unless these values are set: renders with them unset are identical. A label key set in more than one value, e.g. in both `sourcegraph.podLabels` and `sourcegraph.selectorLabelsOverride`, is now rendered once instead of twice, which Kustomize and `kubeconform -strict` rejected. **BREAKING**: the render now fails if these values set a label the chart sets itself (`app`, `deploy`, `group`, `type`, `worker-replica`, `category`, `app.kubernetes.io/component`, or a standard Helm label), or if a pod label sets `app`, `deploy`, `group`, `type`, or `worker-replica`, or gives a selector label a different value. Pod labels may set `app.kubernetes.io/component`, which the chart does not set on pods. Before, the key was rendered twice, and Helm kept the last one, so e.g. `serviceLabels` could replace `app` on a Service. Remove such keys from your values before upgrading. See [Labels](README.md#labels)
- Added `frontendInternal.serviceLabels`, `frontendInternal.serviceAnnotations`, and `frontendInternal.serviceType` for the `sourcegraph-frontend-internal` Service, so it can have different labels, annotations, and type from the `sourcegraph-frontend` Service. If unset, they fall back to `frontend.serviceLabels`, `frontend.serviceAnnotations`, and `frontend.internalServiceType`, as before; set `frontendInternal.serviceLabels` or `serviceAnnotations` to `{}` for none.
- Added `openTelemetry.gateway.podSecurityContext`, `openTelemetry.gateway.extraVolumes`, and `openTelemetry.gateway.extraVolumeMounts`, like other components have, so e.g. an `extraInitContainers` container can write an exporter API key to a volume the `otel-collector` container reads with `openTelemetry.gateway.command`
Expand Down
64 changes: 64 additions & 0 deletions charts/sourcegraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,30 @@ pod labels may set them, except on `jaeger`. Services do not get
`sourcegraph.labels`, because Prometheus copies a Service's labels onto the
metrics it scrapes from it.

## 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.
They run next to the `indexed-search` StatefulSet, with different workload,
Service, and PVC names.

- `zoektIndexer.enabled` and `zoektSearcher.enabled` render the two services.
- `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.
Kubernetes keeps a StatefulSet's PVCs after the StatefulSet is deleted, so
delete the `data-indexed-search-*` PVCs to free their disks.

The chart does not configure the Zoekt indexer itself. It stays off until
`SRC_ZOEKT_INDEXER_ENABLED` is set, along with settings such as
`SRC_ZOEKT_SEARCHER_ROUTING` and `SRC_ZOEKT_WARM_REPLICAS`, identically in the
`env` of `frontend`, `worker`, `searcher`, `zoektSearcher`, and `zoektIndexer`.

## Configuration Options

Reference the below chart for all available configuration parameters.
Expand Down Expand Up @@ -288,6 +312,7 @@ 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 |
Expand Down Expand Up @@ -565,3 +590,42 @@ 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 |
| zoektIndexer.args | list | `[]` | Arguments for the indexer container |
| zoektIndexer.command | list | `[]` | Command for the indexer container, replacing the image's entrypoint |
| zoektIndexer.enabled | bool | `false` | Enable the `zoekt-indexer` Deployment, which builds indexed search shards and publishes them through object storage for the Zoekt searchers. Experimental: it does nothing until `SRC_ZOEKT_INDEXER_ENABLED` is set. See [Zoekt indexer and searchers](#zoekt-indexer-and-searchers). |
| zoektIndexer.env | object | `{"DEPLOY_TYPE":{"value":"helm"}}` | Environment variables for the `zoekt-indexer` container |
| zoektIndexer.image.defaultTag | string | `"{{ .Chart.AppVersion }}"` | Docker image tag for the `zoekt-indexer` image |
| zoektIndexer.image.name | string | `"zoekt-indexer"` | Docker image name for the `zoekt-indexer` image |
| zoektIndexer.image.repository | string | `""` | Override the global sourcegraph.image.repository for the `zoekt-indexer` image |
| zoektIndexer.image.tag | string | `""` | Override the tag of the `zoekt-indexer` image |
| zoektIndexer.name | string | `"zoekt-indexer"` | Name of the indexer Deployment, its metrics Service, PodDisruptionBudget, and ServiceAccount |
| zoektIndexer.podDisruptionBudget | object | `{}` | Pod disruption budget for `zoekt-indexer`. Configure either `minAvailable` or `maxUnavailable` to enable it. |
| zoektIndexer.replicaCount | int | `2` | Number of `zoekt-indexer` pods |
| zoektIndexer.resources | object | `{"limits":{"cpu":"4","memory":"4G"},"requests":{"cpu":"1","memory":"1G"}}` | Resource requests & limits for the `zoekt-indexer` container |
| zoektIndexer.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 |
| zoektIndexer.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 |
| zoektIndexer.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 |
| zoektIndexer.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `zoekt-indexer` |
| zoektIndexer.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
| 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.enabled | bool | `false` | Enable the `zoekt-searcher` StatefulSet, which downloads and serves the shards the Zoekt indexers publish. Experimental: the frontend searches it only with `SRC_ZOEKT_INDEXER_ENABLED` set. The indexer pods share its security contexts and scheduling settings. See [Zoekt indexer and searchers](#zoekt-indexer-and-searchers). |
| 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 |
| 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` |
| 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 |
24 changes: 24 additions & 0 deletions charts/sourcegraph/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,30 @@ pod labels may set them, except on `jaeger`. Services do not get
`sourcegraph.labels`, because Prometheus copies a Service's labels onto the
metrics it scrapes from it.

## 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.
They run next to the `indexed-search` StatefulSet, with different workload,
Service, and PVC names.

- `zoektIndexer.enabled` and `zoektSearcher.enabled` render the two services.
- `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.
Kubernetes keeps a StatefulSet's PVCs after the StatefulSet is deleted, so
delete the `data-indexed-search-*` PVCs to free their disks.

The chart does not configure the Zoekt indexer itself. It stays off until
`SRC_ZOEKT_INDEXER_ENABLED` is set, along with settings such as
`SRC_ZOEKT_SEARCHER_ROUTING` and `SRC_ZOEKT_WARM_REPLICAS`, identically in the
`env` of `frontend`, `worker`, `searcher`, `zoektSearcher`, and `zoektIndexer`.

## Configuration Options

Reference the below chart for all available configuration parameters.
Expand Down
29 changes: 29 additions & 0 deletions charts/sourcegraph/templates/_helpers/_zoekt.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{/*
Render the image reference for a Zoekt indexer or searcher image.
Usage: include "sourcegraph.zoekt.image" (list . .Values.zoektSearcher.image)
The tag defaults to the chart appVersion when the image sets no defaultTag.
*/}}
{{- define "sourcegraph.zoekt.image" -}}
{{- $top := index . 0 -}}
{{- $image := index . 1 -}}
{{- $repository := default $top.Values.sourcegraph.image.repository $image.repository -}}
{{- $defaultTag := tpl (toString (default "{{ .Chart.AppVersion }}" $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 empty INDEXED_SEARCH_SERVERS and INDEXED_SEARCH_INDEXER for the frontend when the
indexed-search StatefulSet is not rendered. Without them the frontend falls back to discovering
the indexed-search StatefulSet, which no longer exists. Settings in frontend.env take precedence.
*/}}
{{- define "sourcegraph.indexedSearch.disabledEnv" -}}
{{- if not .Values.indexedSearch.enabled -}}
{{- range $name := list "INDEXED_SEARCH_SERVERS" "INDEXED_SEARCH_INDEXER" }}
{{- if not (hasKey $.Values.frontend.env $name) }}
- name: {{ $name }}
value: ""
{{- end }}
{{- end }}
{{- end -}}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ spec:
{{- end }}
{{- include "sourcegraph.redisConnection" .| nindent 8 }}
{{- include "sourcegraph.openTelemetryEnv" . | nindent 8 }}
{{- with include "sourcegraph.indexedSearch.disabledEnv" . }}{{ . | nindent 8 }}{{- end }}
terminationMessagePolicy: FallbackToLogsOnError
livenessProbe:
httpGet:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.indexedSearch.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
@@ -1,4 +1,4 @@
{{- if .Values.indexedSearch.podDisruptionBudget }}
{{- if and .Values.indexedSearch.enabled .Values.indexedSearch.podDisruptionBudget }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.indexedSearch.enabled -}}
apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -30,3 +31,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
@@ -1,4 +1,4 @@
{{- if .Values.indexedSearch.serviceAccount.create -}}
{{- if and .Values.indexedSearch.enabled .Values.indexedSearch.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.indexedSearch.enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand Down Expand Up @@ -168,3 +169,4 @@ spec:
requests:
storage: {{ .Values.indexedSearch.storageSize }}
storageClassName: {{ .Values.storageClass.name }}
{{- end }}
Loading
Loading