|
1 | | -apiVersion: apps/v1 |
2 | | -kind: Deployment |
3 | | -metadata: |
4 | | - annotations: |
5 | | - description: Manages background processes. |
6 | | - labels: |
7 | | - {{- include "sourcegraph.labels" . | nindent 4 }} |
8 | | - {{- if .Values.worker.labels }} |
9 | | - {{- toYaml .Values.worker.labels | nindent 4 }} |
10 | | - {{- end }} |
11 | | - deploy: sourcegraph |
12 | | - app.kubernetes.io/component: worker |
13 | | - name: {{ .Values.worker.name }} |
14 | | -spec: |
15 | | - minReadySeconds: 10 |
16 | | - replicas: {{ .Values.worker.replicaCount }} |
17 | | - revisionHistoryLimit: {{ .Values.sourcegraph.revisionHistoryLimit }} |
18 | | - selector: |
19 | | - matchLabels: |
20 | | - {{- include "sourcegraph.selectorLabels" . | nindent 6 }} |
21 | | - app: worker |
22 | | - strategy: |
23 | | - rollingUpdate: |
24 | | - maxSurge: 1 |
25 | | - maxUnavailable: 1 |
26 | | - type: RollingUpdate |
27 | | - template: |
28 | | - metadata: |
29 | | - annotations: |
30 | | - kubectl.kubernetes.io/default-container: worker |
31 | | - {{- include "sourcegraph.redisChecksum" . | nindent 8 }} |
32 | | - {{- if .Values.sourcegraph.podAnnotations }} |
33 | | - {{- toYaml .Values.sourcegraph.podAnnotations | nindent 8 }} |
34 | | - {{- end }} |
35 | | - {{- if .Values.worker.podAnnotations }} |
36 | | - {{- toYaml .Values.worker.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.worker.podLabels }} |
44 | | - {{- toYaml .Values.worker.podLabels | nindent 8 }} |
45 | | - {{- end }} |
46 | | - deploy: sourcegraph |
47 | | - app: worker |
48 | | - spec: |
49 | | - containers: |
50 | | - - name: worker |
51 | | - env: |
52 | | - {{- include "sourcegraph.redisConnection" .| nindent 8 }} |
53 | | - {{- range $name, $item := .Values.worker.env}} |
54 | | - - name: {{ $name }} |
55 | | - {{- $item | toYaml | nindent 10 }} |
56 | | - {{- end }} |
57 | | - {{- if .Values.blobstore.enabled }} |
58 | | - - name: PRECISE_CODE_INTEL_UPLOAD_BACKEND |
59 | | - value: blobstore |
60 | | - - name: PRECISE_CODE_INTEL_UPLOAD_AWS_ENDPOINT |
61 | | - value: http://blobstore:9000 |
62 | | - {{- end }} |
63 | | - - name: POD_NAME |
64 | | - valueFrom: |
65 | | - fieldRef: |
66 | | - fieldPath: metadata.name |
67 | | - {{- include "sourcegraph.openTelemetryEnv" . | nindent 8 }} |
68 | | - image: {{ include "sourcegraph.image" (list . "worker" ) }} |
69 | | - imagePullPolicy: {{ .Values.sourcegraph.image.pullPolicy }} |
70 | | - {{- with .Values.worker.args }} |
71 | | - args: |
72 | | - {{- toYaml . | nindent 8 }} |
73 | | - {{- end }} |
74 | | - terminationMessagePolicy: FallbackToLogsOnError |
75 | | - livenessProbe: |
76 | | - httpGet: |
77 | | - path: /healthz |
78 | | - port: debug |
79 | | - scheme: HTTP |
80 | | - initialDelaySeconds: 60 |
81 | | - timeoutSeconds: 5 |
82 | | - readinessProbe: |
83 | | - httpGet: |
84 | | - path: /ready |
85 | | - port: debug |
86 | | - scheme: HTTP |
87 | | - periodSeconds: 5 |
88 | | - timeoutSeconds: 5 |
89 | | - ports: |
90 | | - - containerPort: 3189 |
91 | | - name: http |
92 | | - - containerPort: 6060 |
93 | | - name: debug |
94 | | - - containerPort: 6996 |
95 | | - name: prom |
96 | | - {{- if not .Values.sourcegraph.localDevMode }} |
97 | | - resources: |
98 | | - {{- toYaml .Values.worker.resources | nindent 10 }} |
99 | | - {{- end }} |
100 | | - securityContext: |
101 | | - {{- toYaml .Values.worker.containerSecurityContext | nindent 10 }} |
102 | | - volumeMounts: |
103 | | - {{- if .Values.worker.extraVolumeMounts }} |
104 | | - {{- toYaml .Values.worker.extraVolumeMounts | nindent 8 }} |
105 | | - {{- end }} |
106 | | - {{- if .Values.worker.extraContainers }} |
107 | | - {{- toYaml .Values.worker.extraContainers | nindent 6 }} |
108 | | - {{- end }} |
109 | | - securityContext: |
110 | | - {{- toYaml .Values.worker.podSecurityContext | nindent 8 }} |
111 | | - {{- include "sourcegraph.nodeSelector" (list . "worker" ) | trim | nindent 6 }} |
112 | | - {{- include "sourcegraph.affinity" (list . "worker" ) | trim | nindent 6 }} |
113 | | - {{- include "sourcegraph.tolerations" (list . "worker" ) | trim | nindent 6 }} |
114 | | - {{- with .Values.sourcegraph.imagePullSecrets }} |
115 | | - imagePullSecrets: |
116 | | - {{- toYaml . | nindent 8 }} |
117 | | - {{- end }} |
118 | | - {{- include "sourcegraph.renderServiceAccountName" (list . "worker") | trim | nindent 6 }} |
119 | | - volumes: |
120 | | - {{- if .Values.worker.extraVolumes }} |
121 | | - {{- toYaml .Values.worker.extraVolumes | nindent 6 }} |
122 | | - {{- end }} |
| 1 | +{{- if not .Values.worker.replicas }} |
| 2 | + {{- include "sourcegraph.worker" (list . "" "" "" .Values.worker.resources ) | nindent 0 }} |
| 3 | +{{- else }} |
| 4 | + {{- $dedicatedJobs := list }} |
| 5 | + {{- range .Values.worker.replicas }} |
| 6 | + {{- $dedicatedJobs = $dedicatedJobs | concat .jobs }} |
| 7 | + {{- end }} |
| 8 | + {{- $primaryBlocklist := join "," ($dedicatedJobs | uniq | sortAlpha) }} |
| 9 | +--- |
| 10 | + {{- include "sourcegraph.worker" (list . "" "all" $primaryBlocklist $.Values.worker.resources) | nindent 0 }} |
| 11 | + |
| 12 | + {{- range $idx, $item := .Values.worker.replicas }} |
| 13 | +--- |
| 14 | + {{- $replicaName := printf "%d" $idx }} |
| 15 | + {{- $allowlist := join "," ($item.jobs | uniq | sortAlpha) }} |
| 16 | + {{- $resources := $.Values.worker.resources -}} |
| 17 | + {{- if $item.resources -}} |
| 18 | + {{- $resources = $item.resources -}} |
| 19 | + {{- end -}} |
| 20 | + {{- include "sourcegraph.worker" (list $ $replicaName $allowlist "" $resources) | nindent 0 }} |
| 21 | + {{- end }} |
| 22 | +{{- end }} |
0 commit comments