blob: ae373343d3b4239a46730c336cf8c5fca30f990e [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
17apiVersion: apps/v1beta1
18kind: StatefulSet
19metadata:
20 name: {{ include "common.fullname" . }}
21 namespace: {{ include "common.namespace" . }}
22 labels:
23 app: {{ include "common.name" . }}
24 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010025 release: {{ include "common.release" . }}
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020026 heritage: {{ .Release.Service }}
27spec:
28 serviceName: {{ .Values.service.name }}
29 replicas: {{ .Values.replicaCount }}
30 template:
31 metadata:
32 labels:
33 app: {{ include "common.name" . }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010034 release: {{ include "common.release" . }}
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020035 spec:
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020036 containers:
37 - name: {{ include "common.name" . }}
38 image: "{{ .Values.dockerHubRepository }}/{{ .Values.image }}"
39 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
40 env:
41 - name: MONGO_INITDB_DATABASE
42 value: "{{ .Values.config.dbName }}"
43 ports:
44 - containerPort: {{ .Values.service.internalPort }}
45 # disable liveness probe when breakpoints set in debugger
46 # so K8s doesn't restart unresponsive container
47 {{- if eq .Values.liveness.enabled true }}
48 livenessProbe:
49 exec:
50 command:
51 - mongo
52 - --eval
53 - "db.adminCommand('ping')"
54 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
55 periodSeconds: {{ .Values.liveness.periodSeconds }}
56 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
57 {{end -}}
58 readinessProbe:
59 tcpSocket:
60 port: {{ .Values.service.internalPort }}
61 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
62 periodSeconds: {{ .Values.readiness.periodSeconds }}
63 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010064 - name: {{ include "common.fullname" . }}-data
65 mountPath: /var/lib/mongo
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020066 resources:
Mandeep Khinda5e3f36a2018-09-24 15:25:42 +000067{{ include "common.resources" . | indent 12 }}
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020068 {{- if .Values.nodeSelector }}
69 nodeSelector:
70{{ toYaml .Values.nodeSelector | indent 10 }}
71 {{- end -}}
72 {{- if .Values.affinity }}
73 affinity:
74{{ toYaml .Values.affinity | indent 10 }}
75 {{- end }}
76 volumes:
77 - name: localtime
78 hostPath:
79 path: /etc/localtime
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010080 {{- if .Values.persistence.enabled }}
81 volumeClaimTemplates:
82 - metadata:
83 name: {{ include "common.fullname" . }}-data
84 labels:
85 name: {{ include "common.fullname" . }}
86 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010087 release: "{{ include "common.release" . }}"
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010088 heritage: "{{ .Release.Service }}"
89 spec:
90 accessModes:
91 - {{ .Values.persistence.accessMode | quote }}
92 storageClassName: {{ include "common.storageClass" . }}
93 resources:
94 requests:
95 storage: {{ .Values.persistence.size | quote }}
96 {{- else }}
97 volumes:
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020098 - name: {{ include "common.fullname" . }}-data
Sylvain Desbureauxe44d1702018-05-07 20:39:16 +020099 emptyDir: {}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100100 {{- end }}