blob: 72a8736e176d95637eb0cc656063fe8033385dec [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
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010017kind: Deployment
BorislavGb36d86c2018-04-01 18:59:54 +030018metadata:
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010019 name: {{ include "common.fullname" . }}-replica
BorislavGb36d86c2018-04-01 18:59:54 +030020 namespace: {{ include "common.namespace" . }}
21 labels:
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010022 app: {{ include "common.name" . }}-replica
BorislavGb36d86c2018-04-01 18:59:54 +030023 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 }}
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010026 name: "{{ .Values.container.name.replica }}"
BorislavGb36d86c2018-04-01 18:59:54 +030027spec:
28 serviceName: {{ .Values.service.name }}
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010029 replicas: 1
BorislavGb36d86c2018-04-01 18:59:54 +030030 template:
31 metadata:
32 labels:
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010033 app: {{ include "common.name" . }}-replica
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010034 release: {{ include "common.release" . }}
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010035 name: "{{ .Values.container.name.replica }}"
BorislavGb36d86c2018-04-01 18:59:54 +030036 spec:
37 initContainers:
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010038 - name: init-sysctl
39 command:
BorislavGb36d86c2018-04-01 18:59:54 +030040 - /bin/sh
41 - -c
42 - |
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010043 chown 26:26 /podroot/;
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010044 chmod 700 /podroot/;
BorislavGb36d86c2018-04-01 18:59:54 +030045 image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.busyboxImage }}
46 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
BorislavGb36d86c2018-04-01 18:59:54 +030047 volumeMounts:
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +010048 - name: {{ include "common.fullname" . }}-data
BorislavGb36d86c2018-04-01 18:59:54 +030049 mountPath: /podroot/
50 containers:
51 - name: {{ include "common.name" . }}
52 image: "{{ .Values.postgresRepository }}/{{ .Values.image }}"
53 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
54 ports:
55 - containerPort: {{ .Values.service.internalPort }}
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010056 name: {{ .Values.service.portName }}
BorislavGb36d86c2018-04-01 18:59:54 +030057 # disable liveness probe when breakpoints set in debugger
58 # so K8s doesn't restart unresponsive container
59 {{- if eq .Values.liveness.enabled true }}
60 livenessProbe:
61 tcpSocket:
62 port: {{ .Values.service.internalPort }}
63 initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
64 periodSeconds: {{ .Values.liveness.periodSeconds }}
65 timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
66 {{end -}}
67 readinessProbe:
68 tcpSocket:
69 port: {{ .Values.service.internalPort }}
70 initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
71 periodSeconds: {{ .Values.readiness.periodSeconds }}
72 env:
73 - name: PGHOST
74 value: /tmp
75 - name: PG_PRIMARY_USER
76 value: primaryuser
77 - name: PG_MODE
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010078 value: replica
BorislavGb36d86c2018-04-01 18:59:54 +030079 - name: PG_PRIMARY_HOST
80 value: "{{.Values.container.name.primary}}"
81 - name: PG_REPLICA_HOST
82 value: "{{.Values.container.name.replica}}"
83 - name: PG_PRIMARY_PORT
84 value: "{{.Values.service.internalPort}}"
85 - name: PG_PRIMARY_PASSWORD
86 valueFrom:
87 secretKeyRef:
88 name: {{ template "common.fullname" . }}
89 key: pg-primary-password
90 - name: PG_USER
91 value: "{{.Values.config.pgUserName}}"
92 - name: PG_PASSWORD
93 valueFrom:
94 secretKeyRef:
95 name: {{ template "common.fullname" . }}
96 key: pg-user-password
97 - name: PG_DATABASE
98 value: "{{.Values.config.pgDatabase}}"
99 - name: PG_ROOT_PASSWORD
100 valueFrom:
101 secretKeyRef:
102 name: {{ template "common.fullname" . }}
103 key: pg-root-password
104 volumeMounts:
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +0100105 - name: pool-hba-conf
106 mountPath: /pgconf/pool_hba.conf
107 subPath: pool_hba.conf
BorislavGb36d86c2018-04-01 18:59:54 +0300108 - mountPath: /pgdata
109 name: {{ include "common.fullname" . }}-data
110 - mountPath: /backup
111 name: {{ include "common.fullname" . }}-backup
112 readOnly: true
113 resources:
Mandeep Khinda5e3f36a2018-09-24 15:25:42 +0000114{{ include "common.resources" . | indent 12 }}
BorislavGb36d86c2018-04-01 18:59:54 +0300115 {{- if .Values.nodeSelector }}
116 nodeSelector:
117{{ toYaml .Values.nodeSelector | indent 10 }}
118 {{- end -}}
119 {{- if .Values.affinity }}
120 affinity:
121{{ toYaml .Values.affinity | indent 10 }}
122 {{- end }}
123 volumes:
124 - name: localtime
125 hostPath:
126 path: /etc/localtime
BorislavGb36d86c2018-04-01 18:59:54 +0300127 - name: {{ include "common.fullname" . }}-backup
128 emptyDir: {}
BorislavGb36d86c2018-04-01 18:59:54 +0300129 - name: {{ include "common.fullname" . }}-data
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +0100130{{- if .Values.persistence.enabled }}
131 persistentVolumeClaim:
132 claimName: {{ include "common.fullname" . }}-replica
Sylvain Desbureauxb7ed2ee2019-11-29 11:35:13 +0100133{{- else }}
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +0100134 emptyDir: {}
135{{ end }}
136 - name: pool-hba-conf
137 configMap:
138 name: {{ include "common.fullname" . }}