Skip to content

Commit 55e0656

Browse files
authored
Embeddings Service (#278)
* Add embeddings service
1 parent 2b4383b commit 55e0656

File tree

7 files changed

+206
-13
lines changed

7 files changed

+206
-13
lines changed

charts/sourcegraph/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Use `**BREAKING**:` to denote a breaking change
88

99
## Unreleased
1010

11+
- Add Embeddings service (disabled by default) for Cody embeddings
12+
1113
## 5.0.1
1214

1315
- Sourcegraph 5.0.1 is now available!

charts/sourcegraph/README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ In addition to the documented values, all services also support the following va
9090
| codeIntelDB.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `codeintel-db` |
9191
| codeIntelDB.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
9292
| codeIntelDB.storageSize | string | `"200Gi"` | PVC Storage Request for `codeintel-db` data volume |
93+
| embeddings.backend | object | `{"EMBEDDINGS_UPLOAD_AWS_ENDPOINT":"http://blobstore:9000","EMBEDDINGS_UPLOAD_BACKEND":"blobstore"}` | Configure the storage backend for embeddings |
94+
| embeddings.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `worker` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
95+
| embeddings.enabled | bool | `false` | Enable `embeddings` |
96+
| embeddings.env | object | `{}` | Environment variables for the `embeddings` container |
97+
| embeddings.extraVolumeMounts | object | `{}` | |
98+
| embeddings.extraVolumes | object | `{}` | |
99+
| embeddings.image.defaultTag | string | `"5.0.2@sha256:fac554b8dc22ee2842228ed56eac059a3671a8ad8d246c8120106508b74bc621"` | Docker image tag for the `embeddings` image |
100+
| embeddings.image.name | string | `"embeddings"` | Docker image name for the `embeddings` image |
101+
| embeddings.name | string | `"embeddings"` | Name of the `embeddings` service |
102+
| embeddings.podSecurityContext | object | `{}` | Security context for the `embeddings` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
103+
| embeddings.resources | object | `{"limits":{"cpu":"8","memory":"64G"},"requests":{"cpu":"4","memory":"32G"}}` | Resource requests & limits for the `worker` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
104+
| embeddings.serviceAccount.annotations | object | `{}` | |
105+
| embeddings.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `embeddings` |
106+
| embeddings.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
93107
| extraResources | list | `[]` | Additional resources to include in the rendered manifest. Templates are supported. |
94108
| 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) |
95109
| frontend.env | object | the chart will add some default environment values | Environment variables for the `frontend` container |
@@ -152,7 +166,7 @@ In addition to the documented values, all services also support the following va
152166
| indexedSearchIndexer.image.defaultTag | string | `"5.0.2@sha256:7a770bfebd2c4d0eeaccb2ae3c7b93208514910d39a13e6289cc0db66b6b444e"` | Docker image tag for the `zoekt-indexserver` image |
153167
| indexedSearchIndexer.image.name | string | `"search-indexer"` | Docker image name for the `zoekt-indexserver` image |
154168
| 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. |
155-
| jaeger.collector.name | string | `""` | Name of jaeger `collector` service |
169+
| jaeger.collector.name | string | `""` | Name of jaeger `collector` service |
156170
| jaeger.collector.serviceAnnotations | object | `{}` | Add extra annotations to jaeger `collector` service |
157171
| jaeger.collector.serviceLabels | object | `{}` | Add extra labels to jaeger `collector` service |
158172
| jaeger.collector.serviceType | string | "ClusterIP" | Kubernetes service type of jaeger `collector` service, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) |
@@ -162,7 +176,7 @@ In addition to the documented values, all services also support the following va
162176
| jaeger.image.name | string | `"jaeger-all-in-one"` | Docker image name for the `jaeger` image |
163177
| jaeger.name | string | `"jaeger"` | Name used by resources. Does not affect service names or PVCs. |
164178
| jaeger.podSecurityContext | object | `{}` | Security context for the `jaeger` pod, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod) |
165-
| jaeger.query.name | string | `""` | Name of jaeger `query` service |
179+
| jaeger.query.name | string | `""` | Name of jaeger `query` service |
166180
| jaeger.query.serviceAnnotations | object | `{}` | Add extra annotations to jaeger `query` service |
167181
| jaeger.query.serviceLabels | object | `{}` | Add extra labels to jaeger `query` service |
168182
| jaeger.query.serviceType | string | "ClusterIP" | Kubernetes service type of jaeger `query` service, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) |
@@ -197,7 +211,7 @@ In addition to the documented values, all services also support the following va
197211
| openTelemetry.agent.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `otel-agent` |
198212
| openTelemetry.agent.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
199213
| openTelemetry.enabled | bool | `true` | |
200-
| 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) |
214+
| 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) |
201215
| 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) |
202216
| 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) |
203217
| openTelemetry.gateway.name | string | `"otel-collector"` | Name used by resources. Does not affect service names or PVCs. |
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{{- if .Values.embeddings.enabled -}}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ .Values.embeddings.name }}
6+
annotations:
7+
description: Handles embeddings which enhance Cody's context fetching
8+
labels:
9+
{{- include "sourcegraph.labels" . | nindent 4 }}
10+
{{- if .Values.embeddings.labels }}
11+
{{- toYaml .Values.embeddings.labels | nindent 4 }}
12+
{{- end }}
13+
deploy: sourcegraph
14+
app.kubernetes.io/component: embeddings
15+
spec:
16+
minReadySeconds: 10
17+
replicas: 1
18+
revisionHistoryLimit: {{ .Values.sourcegraph.revisionHistoryLimit }}
19+
selector:
20+
matchLabels:
21+
{{- include "sourcegraph.selectorLabels" . | nindent 6 }}
22+
app: {{ .Values.embeddings.name }}
23+
strategy:
24+
rollingUpdate:
25+
maxSurge: 1
26+
maxUnavailable: 0
27+
type: RollingUpdate
28+
template:
29+
metadata:
30+
annotations:
31+
{{- if .Values.sourcegraph.podAnnotations }}
32+
{{- toYaml .Values.sourcegraph.podAnnotations | nindent 8 }}
33+
{{- end }}
34+
{{- if .Values.embeddings.podAnnotations }}
35+
{{- toYaml .Values.embeddings.podAnnotations | nindent 8 }}
36+
{{- end }}
37+
labels:
38+
app: {{ .Values.embeddings.name }}
39+
app.kubernetes.io/component: embeddings
40+
deploy: sourcegraph
41+
{{- include "sourcegraph.selectorLabels" . | nindent 8 }}
42+
{{- if .Values.sourcegraph.podLabels }}
43+
{{- toYaml .Values.sourcegraph.podLabels | nindent 8 }}
44+
{{- end }}
45+
{{- if .Values.embeddings.podLabels }}
46+
{{- toYaml .Values.embeddings.podLabels | nindent 8 }}
47+
{{- end }}
48+
spec:
49+
containers:
50+
- name: {{ .Values.embeddings.name }}
51+
image: {{ include "sourcegraph.image" (list . "embeddings") }}
52+
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
53+
env:
54+
{{- range $name, $item := .Values.embeddings.env }}
55+
- name: {{ $name }}
56+
{{- $item | toYaml | nindent 10 }}
57+
{{- end }}
58+
{{- range $name, $item := .Values.embeddings.backend }}
59+
- name: {{ $name }}
60+
value: {{ $item | quote }}
61+
{{- end }}
62+
ports:
63+
- containerPort: 9991
64+
name: http
65+
protocol: TCP
66+
volumeMounts:
67+
{{- if .Values.embeddings.extraVolumeMounts }}
68+
{{- toYaml .Values.embeddings.extraVolumeMounts | nindent 8 }}
69+
{{- end }}
70+
{{- if not .Values.sourcegraph.localDevMode}}
71+
resources:
72+
{{- toYaml .Values.embeddings.resources | nindent 10 }}
73+
{{- end }}
74+
securityContext:
75+
{{- toYaml .Values.embeddings.containerSecurityContext | nindent 10 }}
76+
securityContext:
77+
{{- toYaml .Values.embeddings.podSecurityContext | nindent 8 }}
78+
{{- include "sourcegraph.nodeSelector" (list . "embeddings" ) | trim | nindent 6 }}
79+
{{- include "sourcegraph.affinity" (list . "embeddings" ) | trim | nindent 6 }}
80+
{{- include "sourcegraph.tolerations" (list . "embeddings" ) | trim | nindent 6 }}
81+
{{- if .Values.embeddings.serviceAccount.create }}
82+
serviceAccountName: {{ .Values.embeddings.serviceAccount.name }}
83+
{{- end}}
84+
volumes:
85+
{{- if .Values.embeddings.extraVolumes }}
86+
{{- toYaml .Values.embeddings.extraVolumes | nindent 6 }}
87+
{{- end }}
88+
{{- end }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- if .Values.embeddings.enabled -}}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
annotations:
6+
prometheus.io/port: "6060"
7+
sourcegraph.prometheus/scrape: "true"
8+
{{- if .Values.frontend.serviceAnnotations }}
9+
{{- toYaml .Values.frontend.serviceAnnotations | nindent 4 }}
10+
{{- end }}
11+
labels:
12+
app: {{ .Values.embeddings.name }}
13+
deploy: sourcegraph
14+
app.kubernetes.io/component: embeddings
15+
{{- if .Values.sourcegraph.serviceLabels }}
16+
{{- toYaml .Values.sourcegraph.serviceLabels | nindent 4 }}
17+
{{- end }}
18+
name: {{ .Values.embeddings.name }}
19+
spec:
20+
ports:
21+
- name: http
22+
port: 9991
23+
protocol: TCP
24+
targetPort: http
25+
selector:
26+
{{- include "sourcegraph.selectorLabels" . | nindent 4 }}
27+
app: {{ .Values.embeddings.name }}
28+
type: {{ .Values.embeddings.serviceType | default "ClusterIP" }}
29+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if and .Values.embeddings.enabled .Values.embeddings.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
labels:
6+
category: rbac
7+
deploy: sourcegraph
8+
app.kubernetes.io/component: {{ .Values.embeddings.name }}
9+
{{- include "sourcegraph.serviceAccountAnnotations" (list . "embeddings") | trim | nindent 2 }}
10+
name: {{ include "sourcegraph.serviceAccountName" (list . "embeddings") }}
11+
{{- end }}

charts/sourcegraph/templates/worker/worker.Deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ spec:
6060
- name: PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT
6161
value: http://blobstore:9000
6262
{{- end }}
63+
{{- if .Values.embeddings.enabled }}
64+
{{- range $name, $item := .Values.embeddings.backend }}
65+
- name: {{ $name }}
66+
value: {{ $item | quote }}
67+
{{- end }}
68+
{{- end }}
6369
- name: POD_NAME
6470
valueFrom:
6571
fieldRef:

charts/sourcegraph/values.yaml

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
sourcegraph:
66
image:
77
# -- Global docker image tag
8-
defaultTag: '{{ .Chart.AppVersion }}'
8+
defaultTag: "{{ .Chart.AppVersion }}"
99
# -- Global docker image pull policy
1010
pullPolicy: IfNotPresent
1111
# -- Global docker image registry or prefix
@@ -39,7 +39,6 @@ sourcegraph:
3939
# -- Add extra labels to all services
4040
serviceLabels: {}
4141

42-
4342
# Generic application configuration options, used by most applications below
4443
# app: # Generally matches directory name
4544
# replicaCount: 1
@@ -283,6 +282,50 @@ codeIntelDB:
283282
# -- PVC Storage Request for `codeintel-db` data volume
284283
storageSize: 200Gi
285284

285+
embeddings:
286+
# -- Enable `embeddings`
287+
enabled: false
288+
# -- Name of the `embeddings` service
289+
name: embeddings
290+
image:
291+
# -- Docker image name for the `embeddings` image
292+
name: "embeddings"
293+
# -- Docker image tag for the `embeddings` image
294+
defaultTag: "5.0.2@sha256:fac554b8dc22ee2842228ed56eac059a3671a8ad8d246c8120106508b74bc621"
295+
# -- Resource requests & limits for the `worker` container,
296+
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
297+
resources:
298+
limits:
299+
cpu: "8"
300+
memory: 64G
301+
requests:
302+
cpu: "4"
303+
memory: 32G
304+
# -- Configure the storage backend for embeddings
305+
backend:
306+
EMBEDDINGS_UPLOAD_BACKEND: "blobstore"
307+
EMBEDDINGS_UPLOAD_AWS_ENDPOINT: "http://blobstore:9000"
308+
# -- Environment variables for the `embeddings` container
309+
env: {}
310+
# -- Security context for the `worker` container,
311+
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container)
312+
containerSecurityContext:
313+
allowPrivilegeEscalation: false
314+
runAsUser: 100
315+
runAsGroup: 101
316+
readOnlyRootFilesystem: true
317+
# -- Security context for the `embeddings` container,
318+
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container)
319+
podSecurityContext: {}
320+
serviceAccount:
321+
# -- Enable creation of ServiceAccount for `embeddings`
322+
create: false
323+
# -- Name of the ServiceAccount to be created or an existing ServiceAccount
324+
name: ""
325+
annotations: {}
326+
extraVolumeMounts: {}
327+
extraVolumes: {}
328+
286329
frontend:
287330
# -- Environment variables for the `frontend` container
288331
# @default -- the chart will add some default environment values
@@ -628,7 +671,7 @@ openTelemetry:
628671
# -- Define trace processors.
629672
# Read how to configure sampling in the [OpenTelemetry documentation](https://docs.sourcegraph.com/admin/observability/opentelemetry#sampling-traces)
630673
processors: {}
631-
# -- Define where traces should be exported to.
674+
# -- Define where traces should be exported to.
632675
# Read how to configure different backends in the [OpenTelemetry documentation](https://opentelemetry.io/docs/collector/configuration/#exporters)
633676
exporters: {}
634677
# -- Define the name of a preexisting secret containing TLS certificates for exporters, which will be mounted under "/tls".
@@ -639,7 +682,7 @@ openTelemetry:
639682
create: false
640683
# -- Name of the ServiceAccount to be created or an existing ServiceAccount
641684
name: ""
642-
685+
643686
agent:
644687
# -- Name used by resources. Does not affect service names or PVCs.
645688
name: "otel-agent"
@@ -679,17 +722,17 @@ nodeExporter:
679722
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
680723
resources:
681724
limits:
682-
cpu: '1'
725+
cpu: "1"
683726
memory: 1Gi
684727
requests:
685-
cpu: '.2'
728+
cpu: ".2"
686729
memory: 100Mi
687730
serviceAccount:
688731
# -- Enable creation of ServiceAccount for `node-exporter`
689732
create: false
690733
# -- Name of the ServiceAccount to be created or an existing ServiceAccount
691734
name: node-exporter
692-
# Share the host process ID namespace.
735+
# Share the host process ID namespace.
693736
hostPID: true
694737
## Additional container arguments for the node-exporter container
695738
extraArgs: []
@@ -709,7 +752,7 @@ nodeExporter:
709752
runAsGroup: 65534
710753
runAsNonRoot: true
711754
runAsUser: 65534
712-
755+
713756
pgsql:
714757
# -- Enable `pgsql` PostgreSQL server
715758
enabled: true
@@ -1168,7 +1211,7 @@ syntectServer:
11681211

11691212
jaeger:
11701213
collector:
1171-
# -- Name of jaeger `collector` service
1214+
# -- Name of jaeger `collector` service
11721215
name: ""
11731216
# -- Add extra annotations to jaeger `collector` service
11741217
serviceAnnotations: {}
@@ -1198,7 +1241,7 @@ jaeger:
11981241
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod)
11991242
podSecurityContext: {}
12001243
query:
1201-
# -- Name of jaeger `query` service
1244+
# -- Name of jaeger `query` service
12021245
name: ""
12031246
# -- Add extra annotations to jaeger `query` service
12041247
serviceAnnotations: {}

0 commit comments

Comments
 (0)