Skip to content

Commit 87ade97

Browse files
Syntactic code intel worker deployment (#526)
1 parent aa327dc commit 87ade97

File tree

5 files changed

+219
-0
lines changed

5 files changed

+219
-0
lines changed

charts/sourcegraph/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,17 @@ In addition to the documented values, all services also support the following va
334334
| symbols.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `symbols` |
335335
| symbols.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
336336
| symbols.storageSize | string | `"12Gi"` | Size of the PVC for symbols pods to store cache data |
337+
| syntacticCodeIntel.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `syntactic-code-intel-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) |
338+
| syntacticCodeIntel.enabled | bool | `false` | |
339+
| syntacticCodeIntel.image.defaultTag | string | `"5.3.2@sha256:ce2181fe845e359e5a1d603dd7d7d4f17bfd73d382a9a5e52149e19c0cc2fdfe"` | Docker image tag for the `syntactic-code-intel-worker` image |
340+
| syntacticCodeIntel.image.name | string | `"syntactic-code-intel-worker"` | Docker image name for the `syntactic-code-intel-worker` image |
341+
| syntacticCodeIntel.name | string | `"syntactic-code-intel-worker"` | Name used by resources. Does not affect service names or PVCs. |
342+
| syntacticCodeIntel.podSecurityContext | object | `{}` | Security context for the `syntactic-code-intel-worker` pod, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod) |
343+
| syntacticCodeIntel.properties.workerPort | int | `3188` | port to whick worker API will bind |
344+
| syntacticCodeIntel.replicaCount | int | `2` | Number of `syntactic-code-intel-worker` pod |
345+
| syntacticCodeIntel.resources | object | `{"limits":{"cpu":"2","memory":"4G"},"requests":{"cpu":"500m","memory":"2G"}}` | Resource requests & limits for the `syntactic-code-intel-worker` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
346+
| syntacticCodeIntel.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `syntactic-code-intel-worker` |
347+
| syntacticCodeIntel.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
337348
| syntectServer.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `syntect-server` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
338349
| syntectServer.image.defaultTag | string | `"5.3.2@sha256:3d16ab2a0203fea85063dcfe2e9d476540ef3274c28881dc4bbd5ca77933d8e8"` | Docker image tag for the `syntect-server` image |
339350
| syntectServer.image.name | string | `"syntax-highlighter"` | Docker image name for the `syntect-server` image |
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{{- if .Values.syntacticCodeIntel.enabled -}}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
annotations:
6+
description: Handles syntactic code intelligence indexing
7+
labels:
8+
{{- include "sourcegraph.labels" . | nindent 4 }}
9+
{{- if .Values.syntacticCodeIntel.labels }}
10+
{{- toYaml .Values.syntacticCodeIntel.labels | nindent 4 }}
11+
{{- end }}
12+
deploy: sourcegraph
13+
app.kubernetes.io/component: syntactic-code-intel
14+
name: {{ .Values.syntacticCodeIntel.name }}
15+
spec:
16+
minReadySeconds: 10
17+
replicas: {{ .Values.syntacticCodeIntel.replicaCount }}
18+
revisionHistoryLimit: {{ .Values.sourcegraph.revisionHistoryLimit }}
19+
selector:
20+
matchLabels:
21+
{{- include "sourcegraph.selectorLabels" . | nindent 6 }}
22+
app: syntactic-code-intel-worker
23+
strategy:
24+
rollingUpdate:
25+
maxSurge: 1
26+
maxUnavailable: 1
27+
type: RollingUpdate
28+
template:
29+
metadata:
30+
annotations:
31+
kubectl.kubernetes.io/default-container: syntactic-code-intel-worker
32+
{{- if .Values.sourcegraph.podAnnotations }}
33+
{{- toYaml .Values.sourcegraph.podAnnotations | nindent 8 }}
34+
{{- end }}
35+
{{- if .Values.syntacticCodeIntel.podAnnotations }}
36+
{{- toYaml .Values.syntacticCodeIntel.podAnnotations | nindent 8 }}
37+
{{- end }}
38+
labels:
39+
{{- include "sourcegraph.selectorLabels" . | nindent 8 }}
40+
{{- if .Values.sourcegraph.podLabels }}
41+
{{- toYaml .Values.sourcegraph.podLabels | nindent 8 }}
42+
{{- end }}
43+
{{- if .Values.syntacticCodeIntel.podLabels }}
44+
{{- toYaml .Values.syntacticCodeIntel.podLabels | nindent 8 }}
45+
{{- end }}
46+
deploy: sourcegraph
47+
app: syntactic-code-intel-worker
48+
spec:
49+
containers:
50+
- name: syntactic-code-intel-worker
51+
env:
52+
{{- range $name, $item := .Values.syntacticCodeIntel.env}}
53+
- name: {{ $name }}
54+
{{- $item | toYaml | nindent 10 }}
55+
{{- end }}
56+
- name: POD_NAME
57+
valueFrom:
58+
fieldRef:
59+
fieldPath: metadata.name
60+
{{- if .Values.blobstore.enabled }}
61+
- name: SYNTACTIC_CODE_INTEL_UPLOAD_BACKEND
62+
value: blobstore
63+
- name: SYNTACTIC_CODE_INTEL_UPLOAD_AWS_ENDPOINT
64+
value: http://blobstore:9000
65+
- name: SYNTACTIC_CODE_INTEL_WORKER_ADDR
66+
value: ":{{ .Values.syntacticCodeIntel.properties.workerPort }}"
67+
{{- end }}
68+
{{- include "sourcegraph.openTelemetryEnv" . | nindent 8 }}
69+
image: {{ include "sourcegraph.image" (list . "syntacticCodeIntel") }}
70+
imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }}
71+
{{- with .Values.syntacticCodeIntel.args }}
72+
args:
73+
{{- toYaml . | nindent 8 }}
74+
{{- end }}
75+
terminationMessagePolicy: FallbackToLogsOnError
76+
livenessProbe:
77+
httpGet:
78+
path: /healthz
79+
port: http
80+
scheme: HTTP
81+
initialDelaySeconds: 60
82+
timeoutSeconds: 5
83+
readinessProbe:
84+
httpGet:
85+
path: /ready
86+
port: debug
87+
scheme: HTTP
88+
periodSeconds: 5
89+
timeoutSeconds: 5
90+
ports:
91+
- containerPort: {{ .Values.syntacticCodeIntel.properties.workerPort }}
92+
name: http
93+
- containerPort: 6060
94+
name: debug
95+
{{- if not .Values.sourcegraph.localDevMode }}
96+
resources:
97+
{{- toYaml .Values.syntacticCodeIntel.resources | nindent 10 }}
98+
{{- end }}
99+
securityContext:
100+
{{- toYaml .Values.syntacticCodeIntel.containerSecurityContext | nindent 10 }}
101+
volumeMounts:
102+
- mountPath: /tmp
103+
name: tmpdir
104+
{{- if .Values.syntacticCodeIntel.extraVolumeMounts }}
105+
{{- toYaml .Values.syntacticCodeIntel.extraVolumeMounts | nindent 8 }}
106+
{{- end }}
107+
{{- if .Values.syntacticCodeIntel.extraContainers }}
108+
{{- toYaml .Values.syntacticCodeIntel.extraContainers | nindent 6 }}
109+
{{- end }}
110+
securityContext:
111+
{{- toYaml .Values.syntacticCodeIntel.podSecurityContext | nindent 8 }}
112+
{{- include "sourcegraph.nodeSelector" (list . "syntacticCodeIntel" ) | trim | nindent 6 }}
113+
{{- include "sourcegraph.affinity" (list . "syntacticCodeIntel" ) | trim | nindent 6 }}
114+
{{- include "sourcegraph.tolerations" (list . "syntacticCodeIntel" ) | trim | nindent 6 }}
115+
{{- with .Values.sourcegraph.imagePullSecrets }}
116+
imagePullSecrets:
117+
{{- toYaml . | nindent 8 }}
118+
{{- end }}
119+
{{- include "sourcegraph.renderServiceAccountName" (list . "syntacticCodeIntel") | trim | nindent 6 }}
120+
volumes:
121+
- emptyDir: {}
122+
name: tmpdir
123+
{{- if .Values.syntacticCodeIntel.extraVolumes }}
124+
{{- toYaml .Values.syntacticCodeIntel.extraVolumes | nindent 6 }}
125+
{{- end }}
126+
{{- end }}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{- if .Values.syntacticCodeIntel.enabled -}}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
annotations:
6+
prometheus.io/port: "6060"
7+
sourcegraph.prometheus/scrape: "true"
8+
{{- if .Values.syntacticCodeIntel.serviceAnnotations }}
9+
{{- toYaml .Values.syntacticCodeIntel.serviceAnnotations | nindent 4 }}
10+
{{- end }}
11+
labels:
12+
app: syntactic-code-intel-worker
13+
deploy: sourcegraph
14+
app.kubernetes.io/component: syntactic-code-intel
15+
{{- if .Values.syntacticCodeIntel.serviceLabels }}
16+
{{- toYaml .Values.syntacticCodeIntel.serviceLabels | nindent 4 }}
17+
{{- end }}
18+
name: syntactic-code-intel-worker
19+
spec:
20+
ports:
21+
- name: http
22+
port: {{ .Values.syntacticCodeIntel.properties.workerPort }}
23+
targetPort: http
24+
- name: debug
25+
port: 6060
26+
targetPort: debug
27+
selector:
28+
{{- include "sourcegraph.selectorLabels" . | nindent 4 }}
29+
app: syntactic-code-intel-worker
30+
type: {{ .Values.syntacticCodeIntel.serviceType | default "ClusterIP" }}
31+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if and .Values.syntacticCodeIntel.enabled .Values.syntacticCodeIntel.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
labels:
6+
category: rbac
7+
deploy: sourcegraph
8+
app.kubernetes.io/component: syntactic-code-intel
9+
{{- include "sourcegraph.serviceAccountAnnotations" (list . "syntacticCodeIntel") | trim | nindent 2 }}
10+
name: {{ include "sourcegraph.serviceAccountName" (list . "syntacticCodeIntel") }}
11+
{{- end }}

charts/sourcegraph/values.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,46 @@ postgresExporter:
797797
cpu: 10m
798798
memory: 50Mi
799799

800+
syntacticCodeIntel:
801+
enabled: false
802+
properties:
803+
# -- port to whick worker API will bind
804+
workerPort: 3188
805+
image:
806+
# -- Docker image tag for the `syntactic-code-intel-worker` image
807+
defaultTag: 5.3.2@sha256:ce2181fe845e359e5a1d603dd7d7d4f17bfd73d382a9a5e52149e19c0cc2fdfe
808+
# -- Docker image name for the `syntactic-code-intel-worker` image
809+
name: "syntactic-code-intel-worker"
810+
# -- Security context for the `syntactic-code-intel-worker` container,
811+
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container)
812+
containerSecurityContext:
813+
allowPrivilegeEscalation: false
814+
runAsUser: 100
815+
runAsGroup: 101
816+
readOnlyRootFilesystem: true
817+
# -- Name used by resources. Does not affect service names or PVCs.
818+
name: "syntactic-code-intel-worker"
819+
# -- Security context for the `syntactic-code-intel-worker` pod,
820+
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod)
821+
podSecurityContext: {}
822+
# -- Number of `syntactic-code-intel-worker` pod
823+
replicaCount: 2
824+
# -- Resource requests & limits for the `syntactic-code-intel-worker` container,
825+
# learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/)
826+
resources:
827+
limits:
828+
cpu: "2"
829+
memory: 4G
830+
requests:
831+
cpu: 500m
832+
memory: 2G
833+
serviceAccount:
834+
# -- Enable creation of ServiceAccount for `syntactic-code-intel-worker`
835+
create: false
836+
# -- Name of the ServiceAccount to be created or an existing ServiceAccount
837+
name: ""
838+
839+
800840
preciseCodeIntel:
801841
# -- Environment variables for the `precise-code-intel-worker` container
802842
env:

0 commit comments

Comments
 (0)