blob: fc06663029cf9ae56d715fd4b33b2bc88c66b1b3 [file] [log] [blame]
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +02001{{/*
2# Copyright © 2018 Orange
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15*/}}
16
milaszki305089c2020-07-07 12:31:21 +000017apiVersion: apps/v1
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020018kind: StatefulSet
Andreas Geissler8c55fdd2023-07-20 11:15:42 +020019metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020020spec:
Andreas Geissler8c55fdd2023-07-20 11:15:42 +020021 selector: {{- include "common.selectors" . | nindent 4 }}
22 serviceName: {{ include "common.servicename" . }}
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020023 replicas: {{ .Values.replicaCount }}
24 template:
Andreas Geissler8c55fdd2023-07-20 11:15:42 +020025 metadata: {{- include "common.templateMetadata" . | nindent 6 }}
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020026 spec:
Krzysztof Opasiak86a28cd2020-09-09 21:23:32 +020027{{ include "common.podSecurityContext" . | indent 6 }}
andreas-geisslerf84cccd2021-07-07 15:40:41 +020028 imagePullSecrets:
29 - name: "{{ include "common.namespace" . }}-docker-registry-key"
Andreas Geissler7baf2db2021-12-10 07:50:46 +000030 initContainers:
31 # we shouldn't need this but for unknown reason, it's fsGroup is not
32 # applied
33 - name: fix-permission
34 command:
35 - /bin/sh
36 args:
37 - -c
38 - |
39 chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /data
40 image: {{ include "repositoryGenerator.image.busybox" . }}
41 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
42 securityContext:
43 runAsUser: 0
44 volumeMounts:
45 - name: {{ include "common.fullname" . }}-data
46 mountPath: /data
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020047 containers:
48 - name: {{ include "common.name" . }}
Sylvain Desbureauxb0864452020-11-19 17:17:17 +010049 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020050 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
Krzysztof Opasiak86a28cd2020-09-09 21:23:32 +020051 command:
52 - docker-entrypoint.sh
53 args:
54 - --nounixsocket
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020055 env:
56 - name: MONGO_INITDB_DATABASE
57 value: "{{ .Values.config.dbName }}"
58 ports:
59 - containerPort: {{ .Values.service.internalPort }}
Andreas Geissler8c55fdd2023-07-20 11:15:42 +020060 name: {{ .Values.service.portName }}
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020061 # disable liveness probe when breakpoints set in debugger
62 # so K8s doesn't restart unresponsive container
63 {{- if eq .Values.liveness.enabled true }}
64 livenessProbe:
65 exec:
66 command:
67 - mongo
68 - --eval
69 - "db.adminCommand('ping')"
70 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
71 periodSeconds: {{ .Values.liveness.periodSeconds }}
72 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
73 {{end -}}
74 readinessProbe:
75 tcpSocket:
76 port: {{ .Values.service.internalPort }}
77 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
78 periodSeconds: {{ .Values.readiness.periodSeconds }}
79 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010080 - name: {{ include "common.fullname" . }}-data
Andreas Geissler7baf2db2021-12-10 07:50:46 +000081 mountPath: /data/db
Sylvain Desbureauxc27b6a32020-09-23 10:39:31 +020082 resources: {{ include "common.resources" . | nindent 12 }}
Krzysztof Opasiak86a28cd2020-09-09 21:23:32 +020083{{ include "common.containerSecurityContext" . | indent 10 }}
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020084 {{- if .Values.nodeSelector }}
85 nodeSelector:
86{{ toYaml .Values.nodeSelector | indent 10 }}
87 {{- end -}}
88 {{- if .Values.affinity }}
89 affinity:
90{{ toYaml .Values.affinity | indent 10 }}
91 {{- end }}
92 volumes:
93 - name: localtime
94 hostPath:
95 path: /etc/localtime
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010096 {{- if .Values.persistence.enabled }}
97 volumeClaimTemplates:
98 - metadata:
99 name: {{ include "common.fullname" . }}-data
100 labels:
101 name: {{ include "common.fullname" . }}
102 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +0100103 release: "{{ include "common.release" . }}"
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100104 heritage: "{{ .Release.Service }}"
105 spec:
106 accessModes:
107 - {{ .Values.persistence.accessMode | quote }}
108 storageClassName: {{ include "common.storageClass" . }}
109 resources:
110 requests:
111 storage: {{ .Values.persistence.size | quote }}
112 {{- else }}
113 volumes:
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +0200114 - name: {{ include "common.fullname" . }}-data
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +0200115 emptyDir: {}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100116 {{- end }}