Merge "Revert "basic auth for so-monitoring""
[oom.git] / kubernetes / common / mongo / templates / statefulset.yaml
1 {{/*
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
17 apiVersion: apps/v1beta1
18 kind: StatefulSet
19 metadata:
20   name: {{ include "common.fullname" . }}
21   namespace: {{ include "common.namespace" . }}
22   labels:
23     app: {{ include "common.name" . }}
24     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
25     release: {{ .Release.Name }}
26     heritage: {{ .Release.Service }}
27 spec:
28   serviceName: {{ .Values.service.name }}
29   replicas: {{ .Values.replicaCount }}
30   template:
31     metadata:
32       labels:
33         app: {{ include "common.name" . }}
34         release: {{ .Release.Name }}
35     spec:
36       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:
64           - name: {{ include "common.fullname" . }}-data
65             mountPath: /var/lib/mongo
66           resources:
67 {{ include "common.resources" . | indent 12 }}
68         {{- 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
80   {{- 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 }}"
87         release: "{{ .Release.Name }}"
88         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:
98       - name: {{ include "common.fullname" . }}-data
99         emptyDir: {}
100   {{- end }}