blob: 5333a0d310fb1c3e71da9c954abc2e0e94bc721e [file] [log] [blame]
BorislavGb36d86c2018-04-01 18:59:54 +03001{{/*
2# Copyright © 2018 Amdocs, AT&T, Bell Canada
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*/}}
16apiVersion: apps/v1beta1
17kind: StatefulSet
18metadata:
19 name: {{ include "common.fullname" . }}
20 namespace: {{ include "common.namespace" . }}
21 labels:
22 app: {{ include "common.name" . }}
23 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010024 release: {{ include "common.release" . }}
BorislavGb36d86c2018-04-01 18:59:54 +030025 heritage: {{ .Release.Service }}
26spec:
27 serviceName: {{ .Values.service.name }}
28 replicas: {{ .Values.replicaCount }}
29 template:
30 metadata:
31 labels:
32 app: {{ include "common.name" . }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010033 release: {{ include "common.release" . }}
BorislavGb36d86c2018-04-01 18:59:54 +030034 spec:
35 initContainers:
36 - command:
37 - /bin/sh
38 - -c
39 - |
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010040 chown -R 26:26 /podroot/;
41 chmod 700 /podroot/;
BorislavGb36d86c2018-04-01 18:59:54 +030042 image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.busyboxImage }}
43 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010044 name: {{ include "common.name" . }}-prepare
BorislavGb36d86c2018-04-01 18:59:54 +030045 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010046 - name: {{ include "common.fullname" . }}-data
BorislavGb36d86c2018-04-01 18:59:54 +030047 mountPath: /podroot/
48 containers:
49 - name: {{ include "common.name" . }}
50 image: "{{ .Values.postgresRepository }}/{{ .Values.image }}"
51 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
52 ports:
53 - containerPort: {{ .Values.service.internalPort }}
54 name: postgres
55 # disable liveness probe when breakpoints set in debugger
56 # so K8s doesn't restart unresponsive container
57 {{- if eq .Values.liveness.enabled true }}
58 livenessProbe:
59 tcpSocket:
60 port: {{ .Values.service.internalPort }}
61 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
62 periodSeconds: {{ .Values.liveness.periodSeconds }}
63 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
64 {{end -}}
65 readinessProbe:
66 tcpSocket:
67 port: {{ .Values.service.internalPort }}
68 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
69 periodSeconds: {{ .Values.readiness.periodSeconds }}
70 env:
71 - name: PGHOST
72 value: /tmp
73 - name: PG_PRIMARY_USER
74 value: primaryuser
75 - name: PG_MODE
76 value: set
77 - name: PG_PRIMARY_HOST
78 value: "{{.Values.container.name.primary}}"
79 - name: PG_REPLICA_HOST
80 value: "{{.Values.container.name.replica}}"
81 - name: PG_PRIMARY_PORT
82 value: "{{.Values.service.internalPort}}"
83 - name: PG_PRIMARY_PASSWORD
84 valueFrom:
85 secretKeyRef:
86 name: {{ template "common.fullname" . }}
87 key: pg-primary-password
88 - name: PG_USER
89 value: "{{.Values.config.pgUserName}}"
90 - name: PG_PASSWORD
91 valueFrom:
92 secretKeyRef:
93 name: {{ template "common.fullname" . }}
94 key: pg-user-password
95 - name: PG_DATABASE
96 value: "{{.Values.config.pgDatabase}}"
97 - name: PG_ROOT_PASSWORD
98 valueFrom:
99 secretKeyRef:
100 name: {{ template "common.fullname" . }}
101 key: pg-root-password
102 volumeMounts:
103 - mountPath: /pgdata
104 name: {{ include "common.fullname" . }}-data
105 - mountPath: /backup
106 name: {{ include "common.fullname" . }}-backup
107 readOnly: true
108 resources:
Mandeep Khinda5e3f36a2018-09-24 15:25:42 +0000109{{ include "common.resources" . | indent 12 }}
BorislavGb36d86c2018-04-01 18:59:54 +0300110 {{- if .Values.nodeSelector }}
111 nodeSelector:
112{{ toYaml .Values.nodeSelector | indent 10 }}
113 {{- end -}}
114 {{- if .Values.affinity }}
115 affinity:
116{{ toYaml .Values.affinity | indent 10 }}
117 {{- end }}
118 volumes:
119 - name: localtime
120 hostPath:
121 path: /etc/localtime
BorislavGb36d86c2018-04-01 18:59:54 +0300122 - name: {{ include "common.fullname" . }}-backup
123 emptyDir: {}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100124{{- if not .Values.persistence.enabled }}
BorislavGb36d86c2018-04-01 18:59:54 +0300125 - name: {{ include "common.fullname" . }}-data
126 emptyDir: {}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100127{{- else }}
BorislavGb36d86c2018-04-01 18:59:54 +0300128 volumeClaimTemplates:
129 - metadata:
130 name: {{ include "common.fullname" . }}-data
131 labels:
132 name: {{ include "common.fullname" . }}
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100133 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +0100134 release: "{{ include "common.release" . }}"
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100135 heritage: "{{ .Release.Service }}"
BorislavGb36d86c2018-04-01 18:59:54 +0300136 spec:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100137 accessModes:
138 - {{ .Values.persistence.accessMode | quote }}
139 storageClassName: {{ include "common.storageClass" . }}
BorislavGb36d86c2018-04-01 18:59:54 +0300140 resources:
141 requests:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100142 storage: {{ .Values.persistence.size | quote }}
143{{- end }}