BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 1 | {{/* |
| 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 | */}} |
| 16 | apiVersion: apps/v1beta1 |
| 17 | kind: StatefulSet |
| 18 | metadata: |
| 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 Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 24 | release: {{ include "common.release" . }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 25 | heritage: {{ .Release.Service }} |
| 26 | spec: |
| 27 | serviceName: {{ .Values.service.name }} |
| 28 | replicas: {{ .Values.replicaCount }} |
| 29 | template: |
| 30 | metadata: |
| 31 | labels: |
| 32 | app: {{ include "common.name" . }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 33 | release: {{ include "common.release" . }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 34 | spec: |
| 35 | initContainers: |
| 36 | - command: |
| 37 | - /bin/sh |
| 38 | - -c |
| 39 | - | |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 40 | chown -R 26:26 /podroot/; |
| 41 | chmod 700 /podroot/; |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 42 | image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.busyboxImage }} |
| 43 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 44 | name: {{ include "common.name" . }}-prepare |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 45 | volumeMounts: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 46 | - name: {{ include "common.fullname" . }}-data |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 47 | 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 Khinda | 5e3f36a | 2018-09-24 15:25:42 +0000 | [diff] [blame] | 109 | {{ include "common.resources" . | indent 12 }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 110 | {{- 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 |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 122 | - name: {{ include "common.fullname" . }}-backup |
| 123 | emptyDir: {} |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 124 | {{- if not .Values.persistence.enabled }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 125 | - name: {{ include "common.fullname" . }}-data |
| 126 | emptyDir: {} |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 127 | {{- else }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 128 | volumeClaimTemplates: |
| 129 | - metadata: |
| 130 | name: {{ include "common.fullname" . }}-data |
| 131 | labels: |
| 132 | name: {{ include "common.fullname" . }} |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 133 | chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 134 | release: "{{ include "common.release" . }}" |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 135 | heritage: "{{ .Release.Service }}" |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 136 | spec: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 137 | accessModes: |
| 138 | - {{ .Values.persistence.accessMode | quote }} |
| 139 | storageClassName: {{ include "common.storageClass" . }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 140 | resources: |
| 141 | requests: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 142 | storage: {{ .Values.persistence.size | quote }} |
| 143 | {{- end }} |