Merge "Fixed override issue"
[it/dep.git] / ric-aux / helm / infrastructure / subcharts / kong / charts / postgresql / templates / statefulset-slaves.yaml
1 {{- if .Values.replication.enabled }}
2 apiVersion: {{ template "postgresql.statefulset.apiVersion" . }}
3 kind: StatefulSet
4 metadata:
5   name: "{{ template "postgresql.fullname" . }}-slave"
6   labels:
7     app: {{ template "postgresql.name" . }}
8     chart: {{ template "postgresql.chart" . }}
9     release: {{ .Release.Name | quote }}
10     heritage: {{ .Release.Service | quote }}
11 {{- with .Values.slave.labels }}
12 {{ toYaml . | indent 4 }}
13 {{- end }}
14 {{- with .Values.slave.annotations }}
15   annotations:
16 {{ toYaml . | indent 4 }}
17 {{- end }}
18 spec:
19   serviceName: {{ template "postgresql.fullname" . }}-headless
20   replicas: {{ .Values.replication.slaveReplicas }}
21   selector:
22     matchLabels:
23       app: {{ template "postgresql.name" . }}
24       release: {{ .Release.Name | quote }}
25       role: slave
26   template:
27     metadata:
28       name: {{ template "postgresql.fullname" . }}
29       labels:
30         app: {{ template "postgresql.name" . }}
31         chart: {{ template "postgresql.chart" . }}
32         release: {{ .Release.Name | quote }}
33         heritage: {{ .Release.Service | quote }}
34         role: slave
35 {{- with .Values.slave.podLabels }}
36 {{ toYaml . | indent 8 }}
37 {{- end }}
38 {{- with .Values.slave.podAnnotations }}
39       annotations:
40 {{ toYaml . | indent 8 }}
41 {{- end }}
42     spec:
43       {{- if .Values.schedulerName }}
44       schedulerName: "{{ .Values.schedulerName }}"
45       {{- end }}
46 {{- include "postgresql.imagePullSecrets" . | indent 6 }}
47       {{- if .Values.slave.nodeSelector }}
48       nodeSelector:
49 {{ toYaml .Values.slave.nodeSelector | indent 8 }}
50       {{- end }}
51       {{- if .Values.slave.affinity }}
52       affinity:
53 {{ toYaml .Values.slave.affinity | indent 8 }}
54       {{- end }}
55       {{- if .Values.slave.tolerations }}
56       tolerations:
57 {{ toYaml .Values.slave.tolerations | indent 8 }}
58       {{- end }}
59       {{- if .Values.terminationGracePeriodSeconds }}
60       terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
61       {{- end }}
62       {{- if .Values.securityContext.enabled }}
63       securityContext:
64         fsGroup: {{ .Values.securityContext.fsGroup }}
65       {{- end }}
66       {{- if .Values.serviceAccount.enabled }}
67       serviceAccountName: {{ default (include "postgresql.fullname" . ) .Values.serviceAccount.name}}
68       {{- end }}
69       {{- if or .Values.slave.extraInitContainers (and .Values.volumePermissions.enabled .Values.persistence.enabled) .Values.shmVolume.enabled }}
70       initContainers:
71       {{- if or (and .Values.volumePermissions.enabled .Values.persistence.enabled) .Values.shmVolume.enabled }}
72         - name: init-chmod-data
73           image: {{ template "postgresql.volumePermissions.image" . }}
74           imagePullPolicy: "{{ .Values.volumePermissions.image.pullPolicy }}"
75           {{- if .Values.resources }}
76           resources: {{- toYaml .Values.resources | nindent 12 }}
77           {{- end }}
78           command:
79             - /bin/sh
80             - -c
81             - |
82               mkdir -p {{ .Values.persistence.mountPath }}/data
83               chmod 700 {{ .Values.persistence.mountPath }}/data
84               find {{ .Values.persistence.mountPath }} -mindepth 0 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \
85                 xargs chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }}
86               {{- if .Values.shmVolume.enabled }}
87               chmod -R 777 /dev/shm
88               {{- end }}
89           securityContext:
90             runAsUser: {{ .Values.volumePermissions.securityContext.runAsUser }}
91           volumeMounts:
92             - name: data
93               mountPath: {{ .Values.persistence.mountPath }}
94               subPath: {{ .Values.persistence.subPath }}
95             {{- if .Values.shmVolume.enabled }}
96             - name: dshm
97               mountPath: /dev/shm
98             {{- end }}
99       {{- end }}
100       {{- if .Values.slave.extraInitContainers }}
101 {{ tpl .Values.slave.extraInitContainers . | indent 8 }}
102       {{- end }}
103       {{- end }}
104       {{- if .Values.slave.priorityClassName }}
105       priorityClassName: {{ .Values.slave.priorityClassName }}
106       {{- end }}
107       containers:
108         - name: {{ template "postgresql.fullname" . }}
109           image: {{ template "postgresql.image" . }}
110           imagePullPolicy: "{{ .Values.image.pullPolicy }}"
111           {{- if .Values.resources }}
112           resources: {{- toYaml .Values.resources | nindent 12 }}
113           {{- end }}
114           {{- if .Values.securityContext.enabled }}
115           securityContext:
116             runAsUser: {{ .Values.securityContext.runAsUser }}
117           {{- end }}
118           env:
119             - name: BITNAMI_DEBUG
120               value: {{ ternary "true" "false" .Values.image.debug | quote }}
121             - name: POSTGRESQL_VOLUME_DIR
122               value: "{{ .Values.persistence.mountPath }}"
123             - name: POSTGRESQL_PORT_NUMBER
124               value: "{{ template "postgresql.port" . }}"
125             {{- if .Values.persistence.mountPath }}
126             - name: PGDATA
127               value: {{ .Values.postgresqlDataDir | quote }}
128             {{- end }}
129             - name: POSTGRES_REPLICATION_MODE
130               value: "slave"
131             - name: POSTGRES_REPLICATION_USER
132               value: {{ include "postgresql.replication.username" . | quote }}
133             {{- if .Values.usePasswordFile }}
134             - name: POSTGRES_REPLICATION_PASSWORD_FILE
135               value: "/opt/bitnami/postgresql/secrets/postgresql-replication-password"
136             {{- else }}
137             - name: POSTGRES_REPLICATION_PASSWORD
138               valueFrom:
139                 secretKeyRef:
140                   name: {{ template "postgresql.secretName" . }}
141                   key: postgresql-replication-password
142             {{- end }}
143             - name: POSTGRES_CLUSTER_APP_NAME
144               value: {{ .Values.replication.applicationName }}
145             - name: POSTGRES_MASTER_HOST
146               value: {{ template "postgresql.fullname" . }}
147             - name: POSTGRES_MASTER_PORT_NUMBER
148               value: {{ include "postgresql.port" . | quote }}
149             {{- if and .Values.postgresqlPostgresPassword (not (eq .Values.postgresqlUsername "postgres")) }}
150             {{- if .Values.usePasswordFile }}
151             - name: POSTGRES_POSTGRES_PASSWORD_FILE
152               value: "/opt/bitnami/postgresql/secrets/postgresql-postgres-password"
153             {{- else }}
154             - name: POSTGRES_POSTGRES_PASSWORD
155               valueFrom:
156                 secretKeyRef:
157                   name: {{ template "postgresql.secretName" . }}
158                   key: postgresql-postgres-password
159             {{- end }}
160             {{- end }}
161             {{- if .Values.usePasswordFile }}
162             - name: POSTGRES_PASSWORD_FILE
163               value: "/opt/bitnami/postgresql/secrets/postgresql-password"
164             {{- else }}
165             - name: POSTGRES_PASSWORD
166               valueFrom:
167                 secretKeyRef:
168                   name: {{ template "postgresql.secretName" . }}
169                   key: postgresql-password
170             {{- end }}
171           ports:
172             - name: tcp-postgresql
173               containerPort: {{ template "postgresql.port" . }}
174           {{- if .Values.livenessProbe.enabled }}
175           livenessProbe:
176             exec:
177               command:
178                 - /bin/sh
179                 - -c
180                 {{- if (include "postgresql.database" .) }}
181                 - exec pg_isready -U {{ include "postgresql.username" . | quote }} -d {{ (include "postgresql.database" .) | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }}
182                 {{- else }}
183                 - exec pg_isready -U {{ include "postgresql.username" . | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }}
184                 {{- end }}
185             initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
186             periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
187             timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
188             successThreshold: {{ .Values.livenessProbe.successThreshold }}
189             failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
190           {{- end }}
191           {{- if .Values.readinessProbe.enabled }}
192           readinessProbe:
193             exec:
194               command:
195                 - /bin/sh
196                 - -c
197                 - -e
198                 {{- include "postgresql.readinessProbeCommand" . | nindent 16 }}
199             initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
200             periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
201             timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
202             successThreshold: {{ .Values.readinessProbe.successThreshold }}
203             failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
204           {{- end }}
205           volumeMounts:
206             {{- if .Values.usePasswordFile }}
207             - name: postgresql-password
208               mountPath: /opt/bitnami/postgresql/secrets/
209             {{- end }}
210             {{- if .Values.shmVolume.enabled }}
211             - name: dshm
212               mountPath: /dev/shm
213             {{- end }}
214             {{- if .Values.persistence.enabled }}
215             - name: data
216               mountPath: {{ .Values.persistence.mountPath }}
217               subPath: {{ .Values.persistence.subPath }}
218             {{ end }}
219             {{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
220             - name: postgresql-extended-config
221               mountPath: /bitnami/postgresql/conf/conf.d/
222             {{- end }}
223             {{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap }}
224             - name: postgresql-config
225               mountPath: /bitnami/postgresql/conf
226             {{- end }}
227             {{- if .Values.slave.extraVolumeMounts }}
228             {{- toYaml .Values.slave.extraVolumeMounts | nindent 12 }}
229             {{- end }}
230       volumes:
231         {{- if .Values.usePasswordFile }}
232         - name: postgresql-password
233           secret:
234             secretName: {{ template "postgresql.secretName" . }}
235         {{- end }}
236         {{- if or (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresqlConfiguration .Values.pgHbaConfiguration .Values.configurationConfigMap}}
237         - name: postgresql-config
238           configMap:
239             name: {{ template "postgresql.configurationCM" . }}
240         {{- end }}
241         {{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresqlExtendedConf .Values.extendedConfConfigMap }}
242         - name: postgresql-extended-config
243           configMap:
244             name: {{ template "postgresql.extendedConfigurationCM" . }}
245         {{- end }}
246         {{- if .Values.shmVolume.enabled }}
247         - name: dshm
248           emptyDir:
249             medium: Memory
250             sizeLimit: 1Gi
251         {{- end }}
252         {{- if not .Values.persistence.enabled }}
253         - name: data
254           emptyDir: {}
255         {{- end }}
256         {{- if .Values.slave.extraVolumes }}
257         {{- toYaml .Values.slave.extraVolumes | nindent 8 }}
258         {{- end }}
259   updateStrategy:
260     type: {{ .Values.updateStrategy.type }}
261     {{- if (eq "Recreate" .Values.updateStrategy.type) }}
262     rollingUpdate: null
263     {{- end }}
264 {{- if .Values.persistence.enabled }}
265   volumeClaimTemplates:
266     - metadata:
267         name: data
268       {{- with .Values.persistence.annotations }}
269         annotations:
270         {{- range $key, $value := . }}
271           {{ $key }}: {{ $value }}
272         {{- end }}
273       {{- end }}
274       spec:
275         accessModes:
276         {{- range .Values.persistence.accessModes }}
277           - {{ . | quote }}
278         {{- end }}
279         resources:
280           requests:
281             storage: {{ .Values.persistence.size | quote }}
282         {{ include "postgresql.storageClass" . }}
283 {{- end }}
284 {{- end }}