Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 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 "+" "_" }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 25 | release: {{ include "common.release" . }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 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" . }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 34 | release: {{ include "common.release" . }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 35 | spec: |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 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: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 64 | - name: {{ include "common.fullname" . }}-data |
| 65 | mountPath: /var/lib/mongo |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 66 | resources: |
Mandeep Khinda | 5e3f36a | 2018-09-24 15:25:42 +0000 | [diff] [blame] | 67 | {{ include "common.resources" . | indent 12 }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 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 |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 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 }}" |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 87 | release: "{{ include "common.release" . }}" |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 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: |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 98 | - name: {{ include "common.fullname" . }}-data |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 99 | emptyDir: {} |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 100 | {{- end }} |