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 |
| 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 }} |
milaszki | 305089c | 2020-07-07 12:31:21 +0000 | [diff] [blame] | 30 | selector: |
| 31 | matchLabels: |
| 32 | app: {{ include "common.name" . }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 33 | template: |
| 34 | metadata: |
| 35 | labels: |
| 36 | app: {{ include "common.name" . }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 37 | release: {{ include "common.release" . }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 38 | spec: |
Krzysztof Opasiak | 86a28cd | 2020-09-09 21:23:32 +0200 | [diff] [blame] | 39 | {{ include "common.podSecurityContext" . | indent 6 }} |
andreas-geissler | f84cccd | 2021-07-07 15:40:41 +0200 | [diff] [blame] | 40 | imagePullSecrets: |
| 41 | - name: "{{ include "common.namespace" . }}-docker-registry-key" |
Andreas Geissler | 7baf2db | 2021-12-10 07:50:46 +0000 | [diff] [blame] | 42 | initContainers: |
| 43 | # we shouldn't need this but for unknown reason, it's fsGroup is not |
| 44 | # applied |
| 45 | - name: fix-permission |
| 46 | command: |
| 47 | - /bin/sh |
| 48 | args: |
| 49 | - -c |
| 50 | - | |
| 51 | chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /data |
| 52 | image: {{ include "repositoryGenerator.image.busybox" . }} |
| 53 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 54 | securityContext: |
| 55 | runAsUser: 0 |
| 56 | volumeMounts: |
| 57 | - name: {{ include "common.fullname" . }}-data |
| 58 | mountPath: /data |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 59 | containers: |
| 60 | - name: {{ include "common.name" . }} |
Sylvain Desbureaux | b086445 | 2020-11-19 17:17:17 +0100 | [diff] [blame] | 61 | image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 62 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
Krzysztof Opasiak | 86a28cd | 2020-09-09 21:23:32 +0200 | [diff] [blame] | 63 | command: |
| 64 | - docker-entrypoint.sh |
| 65 | args: |
| 66 | - --nounixsocket |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 67 | env: |
| 68 | - name: MONGO_INITDB_DATABASE |
| 69 | value: "{{ .Values.config.dbName }}" |
| 70 | ports: |
| 71 | - containerPort: {{ .Values.service.internalPort }} |
| 72 | # disable liveness probe when breakpoints set in debugger |
| 73 | # so K8s doesn't restart unresponsive container |
| 74 | {{- if eq .Values.liveness.enabled true }} |
| 75 | livenessProbe: |
| 76 | exec: |
| 77 | command: |
| 78 | - mongo |
| 79 | - --eval |
| 80 | - "db.adminCommand('ping')" |
| 81 | initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} |
| 82 | periodSeconds: {{ .Values.liveness.periodSeconds }} |
| 83 | timeoutSeconds: {{ .Values.liveness.timeoutSeconds }} |
| 84 | {{end -}} |
| 85 | readinessProbe: |
| 86 | tcpSocket: |
| 87 | port: {{ .Values.service.internalPort }} |
| 88 | initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} |
| 89 | periodSeconds: {{ .Values.readiness.periodSeconds }} |
| 90 | volumeMounts: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 91 | - name: {{ include "common.fullname" . }}-data |
Andreas Geissler | 7baf2db | 2021-12-10 07:50:46 +0000 | [diff] [blame] | 92 | mountPath: /data/db |
Sylvain Desbureaux | c27b6a3 | 2020-09-23 10:39:31 +0200 | [diff] [blame] | 93 | resources: {{ include "common.resources" . | nindent 12 }} |
Krzysztof Opasiak | 86a28cd | 2020-09-09 21:23:32 +0200 | [diff] [blame] | 94 | {{ include "common.containerSecurityContext" . | indent 10 }} |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 95 | {{- if .Values.nodeSelector }} |
| 96 | nodeSelector: |
| 97 | {{ toYaml .Values.nodeSelector | indent 10 }} |
| 98 | {{- end -}} |
| 99 | {{- if .Values.affinity }} |
| 100 | affinity: |
| 101 | {{ toYaml .Values.affinity | indent 10 }} |
| 102 | {{- end }} |
| 103 | volumes: |
| 104 | - name: localtime |
| 105 | hostPath: |
| 106 | path: /etc/localtime |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 107 | {{- if .Values.persistence.enabled }} |
| 108 | volumeClaimTemplates: |
| 109 | - metadata: |
| 110 | name: {{ include "common.fullname" . }}-data |
| 111 | labels: |
| 112 | name: {{ include "common.fullname" . }} |
| 113 | chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 114 | release: "{{ include "common.release" . }}" |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 115 | heritage: "{{ .Release.Service }}" |
| 116 | spec: |
| 117 | accessModes: |
| 118 | - {{ .Values.persistence.accessMode | quote }} |
| 119 | storageClassName: {{ include "common.storageClass" . }} |
| 120 | resources: |
| 121 | requests: |
| 122 | storage: {{ .Values.persistence.size | quote }} |
| 123 | {{- else }} |
| 124 | volumes: |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 125 | - name: {{ include "common.fullname" . }}-data |
Sylvain Desbureaux | e44d170 | 2018-05-07 20:39:16 +0200 | [diff] [blame] | 126 | emptyDir: {} |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 127 | {{- end }} |