Skip to content

Commit 5dffc4a

Browse files
Move the helpers this branch changes out of _helpers.tpl
sourcegraph.otelCollector.metricsReaders moves to _helpers/_otelCollector.tpl, and the dind chart's executor.deployment moves to _helpers/_executorDeployment.tpl, each with its comment and otherwise unchanged. No _helpers.tpl gains a line on this branch any more: every helper it adds or changes is in a one-topic file under _helpers/. Renders are byte-identical. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
1 parent 591d864 commit 5dffc4a

4 files changed

Lines changed: 251 additions & 252 deletions

File tree

‎charts/sourcegraph-executor/dind/templates/_helpers.tpl‎

Lines changed: 1 addition & 239 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ tolerations:
7575
{{- end }}
7676
{{- end }}
7777

78+
7879
{{- define "executor.name" -}}
7980
{{- if .Values.executor.queueName -}}
8081
executor-{{.Values.executor.queueName}}
@@ -91,245 +92,6 @@ executor-{{join "-" .Values.executor.queueNames }}
9192
{{- $config | toPrettyJson }}
9293
{{- end }}
9394

94-
{{/*
95-
Render a single executor Deployment.
96-
Usage: include "executor.deployment" (dict "root" $ "name" "executor-foo" "queueName" "foo" "queueNames" (list) "replicaCount" 1 "resources" $res "env" $env)
97-
*/}}
98-
{{- define "executor.deployment" -}}
99-
{{- $r := .root -}}
100-
apiVersion: apps/v1
101-
kind: Deployment
102-
metadata:
103-
name: {{ .name }}
104-
annotations:
105-
description: Runs sourcegraph executors
106-
kubectl.kubernetes.io/default-container: executor
107-
labels:
108-
{{- include "sourcegraph.labels" $r | nindent 4 }}
109-
{{- if $r.Values.executor.labels }}
110-
{{- toYaml $r.Values.executor.labels | nindent 4 }}
111-
{{- end }}
112-
app: {{ .name }}
113-
deploy: sourcegraph
114-
sourcegraph-resource-requires: no-cluster-admin
115-
app.kubernetes.io/component: executor
116-
spec:
117-
selector:
118-
matchLabels:
119-
{{- include "sourcegraph.selectorLabels" $r | nindent 6 }}
120-
app: {{ .name }}
121-
minReadySeconds: 10
122-
replicas: {{ .replicaCount }}
123-
revisionHistoryLimit: 10
124-
strategy:
125-
rollingUpdate:
126-
maxSurge: 1
127-
maxUnavailable: 1
128-
type: RollingUpdate
129-
template:
130-
metadata:
131-
annotations:
132-
kubectl.kubernetes.io/default-container: executor
133-
checksum/docker-config: {{ include "dind.daemonConfig" $r | sha256sum }}
134-
{{- if $r.Values.sourcegraph.podAnnotations }}
135-
{{- toYaml $r.Values.sourcegraph.podAnnotations | nindent 8 }}
136-
{{- end }}
137-
{{- if $r.Values.executor.podAnnotations }}
138-
{{- toYaml $r.Values.executor.podAnnotations | nindent 8 }}
139-
{{- end }}
140-
labels:
141-
{{- include "sourcegraph.podLabels" (list $r $r.Values.executor) | nindent 8 }}
142-
app: {{ .name }}
143-
deploy: sourcegraph
144-
sourcegraph-resource-requires: no-cluster-admin
145-
app.kubernetes.io/component: executor
146-
spec:
147-
{{- with $r.Values.executor.podSecurityContext }}
148-
securityContext:
149-
{{- toYaml . | nindent 8 }}
150-
{{- end }}
151-
containers:
152-
- name: executor
153-
image: {{ include "sourcegraph.image" (list $r "executor") }}
154-
imagePullPolicy: {{ $r.Values.sourcegraph.image.pullPolicy }}
155-
livenessProbe:
156-
httpGet:
157-
path: /healthz
158-
port: http-debug
159-
scheme: HTTP
160-
initialDelaySeconds: 60
161-
timeoutSeconds: 5
162-
readinessProbe:
163-
httpGet:
164-
path: /healthz
165-
port: http-debug
166-
scheme: HTTP
167-
periodSeconds: 5
168-
timeoutSeconds: 5
169-
ports:
170-
- name: http-debug
171-
containerPort: 8080
172-
terminationMessagePolicy: FallbackToLogsOnError
173-
env:
174-
- name: EXECUTOR_FRONTEND_URL
175-
value: {{ $r.Values.executor.frontendUrl | quote }}
176-
- name: EXECUTOR_FRONTEND_PASSWORD
177-
{{- if $r.Values.executor.frontendExistingSecret }}
178-
valueFrom:
179-
secretKeyRef:
180-
name: {{ $r.Values.executor.frontendExistingSecret }}
181-
key: EXECUTOR_FRONTEND_PASSWORD
182-
{{- else }}
183-
value: {{ $r.Values.executor.frontendPassword | quote }}
184-
{{- end }}
185-
{{- if .queueNames }}
186-
- name: EXECUTOR_QUEUE_NAMES
187-
value: {{ join "," .queueNames | quote }}
188-
{{- else }}
189-
- name: EXECUTOR_QUEUE_NAME
190-
value: {{ .queueName | quote }}
191-
{{- end }}
192-
- name: SRC_LOG_LEVEL
193-
value: {{ $r.Values.executor.log.level | quote }}
194-
- name: SRC_LOG_FORMAT
195-
value: {{ $r.Values.executor.log.format | quote }}
196-
- name: EXECUTOR_MAXIMUM_RUNTIME_PER_JOB
197-
value: {{ $r.Values.executor.maximumRuntimePerJob | quote }}
198-
- name: EXECUTOR_USE_FIRECRACKER
199-
value: "false"
200-
- name: EXECUTOR_USE_KUBERNETES
201-
value: "false"
202-
- name: EXECUTOR_HEALTH_SERVER_ADDR
203-
value: ":8080"
204-
- name: EXECUTOR_JOB_NUM_CPUS
205-
value: "0"
206-
- name: EXECUTOR_JOB_MEMORY
207-
value: "0"
208-
- name: DOCKER_HOST
209-
value: tcp://localhost:2375
210-
- name: TMPDIR
211-
value: /scratch
212-
{{- range $name, $item := .env }}
213-
- name: {{ $name }}
214-
{{- $item | toYaml | nindent 14 }}
215-
{{- end }}
216-
volumeMounts:
217-
- mountPath: /scratch
218-
name: executor-scratch
219-
{{- with .resources }}
220-
resources:
221-
{{- toYaml . | nindent 12 }}
222-
{{- end }}
223-
- name: dind
224-
image: "{{ $r.Values.dind.image.registry }}/{{ $r.Values.dind.image.repository }}:{{ $r.Values.dind.image.tag }}"
225-
imagePullPolicy: {{ $r.Values.sourcegraph.image.pullPolicy }}
226-
securityContext:
227-
{{- if $r.Values.dind.gVisor.enabled }}
228-
{{- toYaml $r.Values.dind.gVisor.securityContext | nindent 12 }}
229-
{{- else }}
230-
privileged: true
231-
{{- end }}
232-
command:
233-
{{- if $r.Values.dind.gVisor.enabled }}
234-
{{- toYaml $r.Values.dind.gVisor.command | nindent 12 }}
235-
{{- else }}
236-
{{- toYaml $r.Values.dind.command | nindent 12 }}
237-
{{- end }}
238-
livenessProbe:
239-
exec:
240-
command:
241-
- wget
242-
- -qO-
243-
- http://127.0.0.1:2375/_ping
244-
initialDelaySeconds: 15
245-
periodSeconds: 5
246-
failureThreshold: 5
247-
readinessProbe:
248-
exec:
249-
command:
250-
- wget
251-
- -qO-
252-
- http://127.0.0.1:2375/_ping
253-
initialDelaySeconds: 20
254-
periodSeconds: 5
255-
failureThreshold: 5
256-
env:
257-
- name: POD_NAME
258-
valueFrom:
259-
fieldRef:
260-
apiVersion: v1
261-
fieldPath: metadata.name
262-
ports:
263-
- containerPort: 2375
264-
protocol: TCP
265-
volumeMounts:
266-
- mountPath: /scratch
267-
name: executor-scratch
268-
- mountPath: /etc/docker/daemon.json
269-
subPath: daemon.json
270-
name: docker-config
271-
{{- if $r.Values.dind.gVisor.enabled }}
272-
- mountPath: /var/lib/docker
273-
name: docker
274-
{{- end }}
275-
enableServiceLinks: false
276-
{{- if $r.Values.dind.gVisor.enabled }}
277-
runtimeClassName: gvisor
278-
{{- end }}
279-
{{- with $r.Values.sourcegraph.nodeSelector }}
280-
nodeSelector:
281-
{{- toYaml . | nindent 8 }}
282-
{{- end }}
283-
{{- with $r.Values.sourcegraph.affinity }}
284-
affinity:
285-
{{- toYaml . | nindent 8 }}
286-
{{- end }}
287-
{{- with include "sourcegraph.priorityClassName" (list $r "executor") | trim }}{{ . | nindent 6 }}{{- end }}
288-
{{- with $r.Values.sourcegraph.tolerations }}
289-
tolerations:
290-
{{- toYaml . | nindent 8 }}
291-
{{- end }}
292-
{{- with $r.Values.sourcegraph.imagePullSecrets }}
293-
imagePullSecrets:
294-
{{- toYaml . | nindent 8 }}
295-
{{- end }}
296-
volumes:
297-
- name: executor-scratch
298-
{{- if eq $r.Values.executor.storage.type "ephemeral" }}
299-
ephemeral:
300-
volumeClaimTemplate:
301-
metadata:
302-
labels:
303-
{{- include "sourcegraph.labels" $r | nindent 18 }}
304-
{{- with $r.Values.executor.storage.labels }}
305-
{{- toYaml . | nindent 18 }}
306-
{{- end }}
307-
deploy: sourcegraph
308-
app.kubernetes.io/component: executor
309-
spec:
310-
accessModes: ["ReadWriteOnce"]
311-
{{- if $r.Values.executor.storage.class }}
312-
storageClassName: {{ $r.Values.executor.storage.class }}
313-
{{- end }}
314-
resources:
315-
requests:
316-
storage: {{ required "executor.storage.size is required when storage.type is ephemeral" $r.Values.executor.storage.size }}
317-
{{- else }}
318-
emptyDir:
319-
{{- if $r.Values.executor.storage.size }}
320-
sizeLimit: {{ $r.Values.executor.storage.size }}
321-
{{- end }}
322-
{{- end }}
323-
- name: docker-config
324-
configMap:
325-
defaultMode: 420
326-
name: docker-config
327-
{{- if $r.Values.dind.gVisor.enabled }}
328-
- name: docker
329-
emptyDir: {}
330-
{{- end }}
331-
{{- end }}
332-
33395
{{/*
33496
Validate that an env dict does not contain managed environment variable names.
33597
Usage: include "executor.validateEnv" (list $envDict "label")

0 commit comments

Comments
 (0)