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 | |
milaszki | 305089c | 2020-07-07 12:31:21 +0000 | [diff] [blame] | 17 | apiVersion: apps/v1 |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 18 | kind: StatefulSet |
Andreas Geissler | 8c55fdd | 2023-07-20 11:15:42 +0200 | [diff] [blame] | 19 | metadata: {{- include "common.resourceMetadata" . | nindent 2 }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 20 | spec: |
Andreas Geissler | 8c55fdd | 2023-07-20 11:15:42 +0200 | [diff] [blame] | 21 | selector: {{- include "common.selectors" . | nindent 4 }} |
| 22 | serviceName: {{ include "common.servicename" . }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 23 | replicas: {{ .Values.replicaCount }} |
| 24 | template: |
Andreas Geissler | 8c55fdd | 2023-07-20 11:15:42 +0200 | [diff] [blame] | 25 | metadata: {{- include "common.templateMetadata" . | nindent 6 }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 26 | spec: |
Krzysztof Opasiak | 86a28cd | 2020-09-09 21:23:32 +0200 | [diff] [blame] | 27 | {{ include "common.podSecurityContext" . | indent 6 }} |
andreas-geissler | f84cccd | 2021-07-07 15:40:41 +0200 | [diff] [blame] | 28 | imagePullSecrets: |
| 29 | - name: "{{ include "common.namespace" . }}-docker-registry-key" |
Andreas Geissler | 7baf2db | 2021-12-10 07:50:46 +0000 | [diff] [blame] | 30 | 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 Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 47 | containers: |
| 48 | - name: {{ include "common.name" . }} |
Sylvain Desbureaux | b086445 | 2020-11-19 17:17:17 +0100 | [diff] [blame] | 49 | image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 50 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
Krzysztof Opasiak | 86a28cd | 2020-09-09 21:23:32 +0200 | [diff] [blame] | 51 | command: |
| 52 | - docker-entrypoint.sh |
| 53 | args: |
| 54 | - --nounixsocket |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 55 | env: |
| 56 | - name: MONGO_INITDB_DATABASE |
| 57 | value: "{{ .Values.config.dbName }}" |
| 58 | ports: |
| 59 | - containerPort: {{ .Values.service.internalPort }} |
Andreas Geissler | 8c55fdd | 2023-07-20 11:15:42 +0200 | [diff] [blame] | 60 | name: {{ .Values.service.portName }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 61 | # 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 Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 80 | - name: {{ include "common.fullname" . }}-data |
Andreas Geissler | 7baf2db | 2021-12-10 07:50:46 +0000 | [diff] [blame] | 81 | mountPath: /data/db |
Sylvain Desbureaux | c27b6a3 | 2020-09-23 10:39:31 +0200 | [diff] [blame] | 82 | resources: {{ include "common.resources" . | nindent 12 }} |
Krzysztof Opasiak | 86a28cd | 2020-09-09 21:23:32 +0200 | [diff] [blame] | 83 | {{ include "common.containerSecurityContext" . | indent 10 }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 84 | {{- 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 Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 96 | {{- 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 Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 103 | release: "{{ include "common.release" . }}" |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 104 | 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 Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 114 | - name: {{ include "common.fullname" . }}-data |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 115 | emptyDir: {} |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 116 | {{- end }} |