blob: d4d74a9d8f7ecc0dc6176f1de2d98b0e62f3155b [file] [log] [blame]
Giorgi Lekveishvili285ab622023-11-22 13:50:45 +04001{{- $root := . -}}
2
3apiVersion: apps/v1
4kind: StatefulSet
5metadata:
6 name: {{ .Release.Name }}-gerrit-replica-statefulset
7 labels:
8 app.kubernetes.io/component: gerrit-replica
9 app.kubernetes.io/instance: {{ .Release.Name }}
10 chart: {{ template "gerrit-replica.chart" . }}
11 heritage: {{ .Release.Service }}
12 release: {{ .Release.Name }}
13 {{- if .Values.additionalLabels }}
14{{ toYaml .Values.additionalLabels | indent 4 }}
15 {{- end }}
16spec:
17 serviceName: {{ .Release.Name }}-gerrit-replica-service
18 replicas: {{ .Values.gerritReplica.replicas }}
19 updateStrategy:
20 rollingUpdate:
21 partition: {{ .Values.gerritReplica.updatePartition }}
22 selector:
23 matchLabels:
24 app.kubernetes.io/component: gerrit-replica
25 app.kubernetes.io/instance: {{ .Release.Name }}
26 template:
27 metadata:
28 labels:
29 app.kubernetes.io/component: gerrit-replica
30 app.kubernetes.io/instance: {{ .Release.Name }}
31 chart: {{ template "gerrit-replica.chart" . }}
32 heritage: {{ .Release.Service }}
33 release: {{ .Release.Name }}
34 {{- if .Values.additionalLabels }}
35{{ toYaml .Values.additionalLabels | indent 8 }}
36 {{- end }}
37 {{- if .Values.gerritReplica.additionalPodLabels }}
38{{ toYaml .Values.gerritReplica.additionalPodLabels | indent 8 }}
39 {{- end }}
40 annotations:
41 chartRevision: "{{ .Release.Revision }}"
42 {{- if .Values.gerritReplica.additionalAnnotations }}
43{{ toYaml .Values.gerritReplica.additionalAnnotations | indent 8 }}
44 {{- end }}
45 spec:
46 {{- with .Values.gerritReplica.tolerations }}
47 tolerations:
48 {{- toYaml . | nindent 8 }}
49 {{- end }}
50 {{- with .Values.gerritReplica.topologySpreadConstraints }}
51 topologySpreadConstraints:
52 {{- toYaml . | nindent 8 }}
53 {{- end }}
54 {{- with .Values.gerritReplica.nodeSelector }}
55 nodeSelector:
56 {{- toYaml . | nindent 8 }}
57 {{- end }}
58 {{- with .Values.gerritReplica.affinity }}
59 affinity:
60 {{- toYaml . | nindent 8 }}
61 {{- end }}
62 {{- with .Values.gerritReplica.priorityClassName }}
63 priorityClassName: {{ . }}
64 {{- end }}
65 terminationGracePeriodSeconds: {{ .Values.gerritReplica.gracefulStopTimeout }}
66 securityContext:
67 fsGroup: 100
68 {{ if .Values.images.registry.ImagePullSecret.name -}}
69 imagePullSecrets:
70 - name: {{ .Values.images.registry.ImagePullSecret.name }}
71 {{- range .Values.images.additionalImagePullSecrets }}
72 - name: {{ . }}
73 {{- end }}
74 {{- end }}
75 initContainers:
76 {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.chownOnStartup }}
77 - name: nfs-init
78 image: {{ .Values.images.busybox.registry -}}/busybox:{{- .Values.images.busybox.tag }}
79 command:
80 - sh
81 - -c
82 args:
83 - |
84 chown 1000:100 /var/mnt/logs
85 chown 1000:100 /var/mnt/git
86 env:
87 - name: POD_NAME
88 valueFrom:
89 fieldRef:
90 fieldPath: metadata.name
91 volumeMounts:
92 - name: logs
93 subPathExpr: "gerrit-replica/$(POD_NAME)"
94 mountPath: "/var/mnt/logs"
95 - name: git-repositories
96 mountPath: "/var/mnt/git"
97 {{- if .Values.nfsWorkaround.idDomain }}
98 - name: nfs-config
99 mountPath: "/etc/idmapd.conf"
100 subPath: idmapd.conf
101 {{- end }}
102 {{- end }}
103 - name: gerrit-init
104 image: {{ template "registry" . }}{{ .Values.gerritReplica.images.gerritInit }}:{{ .Values.images.version }}
105 imagePullPolicy: {{ .Values.images.imagePullPolicy }}
106 env:
107 - name: POD_NAME
108 valueFrom:
109 fieldRef:
110 fieldPath: metadata.name
111 volumeMounts:
112 - name: gerrit-site
113 mountPath: "/var/gerrit"
114 - name: git-repositories
115 mountPath: "/var/mnt/git"
116 - name: logs
117 subPathExpr: "gerrit-replica/$(POD_NAME)"
118 mountPath: "/var/mnt/logs"
119 - name: gerrit-init-config
120 mountPath: "/var/config/gerrit-init.yaml"
121 subPath: gerrit-init.yaml
122 {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.idDomain }}
123 - name: nfs-config
124 mountPath: "/etc/idmapd.conf"
125 subPath: idmapd.conf
126 {{- end }}
127 {{- if and .Values.gerritReplica.pluginManagement.cache.enabled }}
128 - name: gerrit-plugin-cache
129 mountPath: "/var/mnt/plugins"
130 {{- end }}
131 - name: gerrit-config
132 mountPath: "/var/mnt/etc/config"
133 - name: gerrit-replica-secure-config
134 mountPath: "/var/mnt/etc/secret"
135 {{ if .Values.caCert -}}
136 - name: tls-ca
137 subPath: ca.crt
138 mountPath: "/var/config/ca.crt"
139 {{- end }}
140 {{- range .Values.gerritReplica.additionalConfigMaps }}
141 - name: {{ .name }}
142 mountPath: "/var/mnt/data/{{ .subDir }}"
143 {{- end }}
144 containers:
145 - name: gerrit-replica
146 image: {{ template "registry" . }}{{ .Values.gerritReplica.images.gerritReplica }}:{{ .Values.images.version }}
147 imagePullPolicy: {{ .Values.images.imagePullPolicy }}
148 env:
149 - name: POD_NAME
150 valueFrom:
151 fieldRef:
152 fieldPath: metadata.name
153 lifecycle:
154 preStop:
155 exec:
156 command:
157 - "/bin/ash"
158 - "-c"
159 - "kill -2 $(pidof java) && tail --pid=$(pidof java) -f /dev/null"
160 ports:
161 - name: http
162 containerPort: 8080
163 {{ if .Values.gerritReplica.service.ssh -}}
164 - name: ssh
165 containerPort: 29418
166 {{- end }}
167 volumeMounts:
168 - name: gerrit-site
169 mountPath: "/var/gerrit"
170 - name: git-repositories
171 mountPath: "/var/mnt/git"
172 - name: logs
173 subPathExpr: "gerrit-replica/$(POD_NAME)"
174 mountPath: "/var/mnt/logs"
175 {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.idDomain }}
176 - name: nfs-config
177 mountPath: "/etc/idmapd.conf"
178 subPath: idmapd.conf
179 {{- end }}
180 - name: gerrit-config
181 mountPath: "/var/mnt/etc/config"
182 - name: gerrit-replica-secure-config
183 mountPath: "/var/mnt/etc/secret"
184 {{- range .Values.gerritReplica.additionalConfigMaps }}
185 - name: {{ .name }}
186 mountPath: "/var/mnt/data/{{ .subDir }}"
187 {{- end }}
188 livenessProbe:
189 httpGet:
190 path: /config/server/healthcheck~status
191 port: http
192{{ toYaml .Values.gerritReplica.livenessProbe | indent 10 }}
193 readinessProbe:
194 httpGet:
195 path: /config/server/healthcheck~status
196 port: http
197{{ toYaml .Values.gerritReplica.readinessProbe | indent 10 }}
198 startupProbe:
199 httpGet:
200 path: /config/server/healthcheck~status
201 port: http
202{{ toYaml .Values.gerritReplica.startupProbe | indent 10 }}
203 resources:
204{{ toYaml .Values.gerritReplica.resources | indent 10 }}
205 {{ if .Values.istio.enabled -}}
206 - name: istio-proxy
207 image: auto
208 lifecycle:
209 preStop:
210 exec:
211 command:
212 - "/bin/sh"
213 - "-c"
214 - "while [ $(netstat -plunt | grep tcp | grep -v envoy | wc -l | xargs) -ne 0 ]; do sleep 1; done"
215 {{- end }}
216 {{ if .Values.promtailSidecar.enabled -}}
217 - name: promtail
218 image: {{ .Values.promtailSidecar.image }}:v{{ .Values.promtailSidecar.version }}
219 imagePullPolicy: {{ .Values.images.imagePullPolicy }}
220 command:
221 - sh
222 - -ec
223 args:
224 - |-
225 /usr/bin/promtail \
226 -config.file=/etc/promtail/promtail.yaml \
227 -client.url={{ .Values.promtailSidecar.loki.url }}/loki/api/v1/push \
228 -client.external-labels=instance=$HOSTNAME
229 env:
230 - name: POD_NAME
231 valueFrom:
232 fieldRef:
233 fieldPath: metadata.name
234 resources:
235{{ toYaml .Values.promtailSidecar.resources | indent 10 }}
236 volumeMounts:
237 - name: promtail-config
238 mountPath: /etc/promtail/promtail.yaml
239 subPath: promtail.yaml
240 - name: promtail-secret
241 mountPath: /etc/promtail/promtail.secret
242 subPath: promtail.secret
243 {{- if not .Values.promtailSidecar.tls.skipVerify }}
244 - name: tls-ca
245 mountPath: /etc/promtail/promtail.ca.crt
246 subPath: ca.crt
247 {{- end }}
248 - name: logs
249 subPathExpr: "gerrit-replica/$(POD_NAME)"
250 mountPath: "/var/gerrit/logs"
251 {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.idDomain }}
252 - name: nfs-config
253 mountPath: "/etc/idmapd.conf"
254 subPath: idmapd.conf
255 {{- end }}
256 {{- end }}
257 volumes:
258 {{ if not .Values.gerritReplica.persistence.enabled -}}
259 - name: gerrit-site
260 emptyDir: {}
261 {{- end }}
262 {{- if and .Values.gerritReplica.pluginManagement.cache.enabled }}
263 - name: gerrit-plugin-cache
264 persistentVolumeClaim:
265 claimName: {{ .Release.Name }}-plugin-cache-pvc
266 {{- end }}
267 - name: git-repositories
268 persistentVolumeClaim:
269 {{- if .Values.gitRepositoryStorage.externalPVC.use }}
270 claimName: {{ .Values.gitRepositoryStorage.externalPVC.name }}
271 {{- else }}
272 claimName: {{ .Release.Name }}-git-repositories-pvc
273 {{- end }}
274 - name: logs
275 {{ if .Values.logStorage.enabled -}}
276 persistentVolumeClaim:
277 {{- if .Values.logStorage.externalPVC.use }}
278 claimName: {{ .Values.logStorage.externalPVC.name }}
279 {{- else }}
280 claimName: {{ .Release.Name }}-log-pvc
281 {{- end }}
282 {{ else -}}
283 emptyDir: {}
284 {{- end }}
285 - name: gerrit-init-config
286 configMap:
287 name: {{ .Release.Name }}-gerrit-init-configmap
288 - name: gerrit-config
289 configMap:
290 name: {{ .Release.Name }}-gerrit-replica-configmap
291 - name: gerrit-replica-secure-config
292 secret:
293 secretName: {{ .Release.Name }}-gerrit-replica-secure-config
294 {{ if .Values.caCert -}}
295 - name: tls-ca
296 secret:
297 secretName: {{ .Release.Name }}-tls-ca
298 {{- end }}
299 {{- range .Values.gerritReplica.additionalConfigMaps }}
300 - name: {{ .name }}
301 configMap:
302 name: {{ if .data }}{{ $root.Release.Name }}-{{ .name }}{{ else }}{{ .name }}{{ end }}
303 {{- end }}
304 {{- if and .Values.nfsWorkaround.enabled .Values.nfsWorkaround.idDomain }}
305 - name: nfs-config
306 configMap:
307 name: {{ .Release.Name }}-nfs-configmap
308 {{- end }}
309 {{ if .Values.promtailSidecar.enabled -}}
310 - name: promtail-config
311 configMap:
312 name: {{ .Release.Name }}-promtail-gerrit-configmap
313 - name: promtail-secret
314 secret:
315 secretName: {{ .Release.Name }}-promtail-secret
316 {{- end }}
317 {{ if .Values.gerritReplica.persistence.enabled -}}
318 volumeClaimTemplates:
319 - metadata:
320 name: gerrit-site
321 labels:
322 app.kubernetes.io/component: gerrit-replica
323 app.kubernetes.io/instance: {{ .Release.Name }}
324 chart: {{ template "gerrit-replica.chart" . }}
325 heritage: {{ .Release.Service }}
326 release: {{ .Release.Name }}
327 {{- if .Values.additionalLabels }}
328{{ toYaml .Values.additionalLabels | indent 8 }}
329 {{- end }}
330 spec:
331 accessModes:
332 - ReadWriteOnce
333 resources:
334 requests:
335 storage: {{ .Values.gerritReplica.persistence.size }}
336 storageClassName: {{ .Values.storageClasses.default.name }}
337 {{- end }}