2 # Copyright © 2018 Amdocs, AT&T, Bell Canada
3 # Copyright © 2020 Samsung Electronics
5 # # Licensed under the Apache License, Version 2.0 (the "License");
6 # # you may not use this file except in compliance with the License.
7 # # You may obtain a copy of the License at
9 # # http://www.apache.org/licenses/LICENSE-2.0
11 # # Unless required by applicable law or agreed to in writing, software
12 # # distributed under the License is distributed on an "AS IS" BASIS,
13 # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # # See the License for the specific language governing permissions and
15 # # limitations under the License.
18 {{- define "common.postgres.deployment" -}}
20 {{- $pgMode := .pgMode }}
24 name: {{ include "common.fullname" $dot }}-{{ $pgMode }}
25 namespace: {{ include "common.namespace" $dot }}
27 app: {{ include "common.name" $dot }}-{{ $pgMode }}
28 chart: {{ $dot.Chart.Name }}-{{ $dot.Chart.Version | replace "+" "_" }}
29 release: {{ include "common.release" $dot }}
30 heritage: {{ $dot.Release.Service }}
31 name: "{{ index $dot.Values "container" "name" $pgMode }}"
36 app: {{ include "common.name" $dot }}-{{ $pgMode }}
40 app: {{ include "common.name" $dot }}-{{ $pgMode }}
41 release: {{ include "common.release" $dot }}
42 name: "{{ index $dot.Values "container" "name" $pgMode }}"
50 function prepare_password {
51 echo -n $1 | sed -e "s/'/''/g"
53 export PG_PRIMARY_PASSWORD=`prepare_password $PG_PRIMARY_PASSWORD_INPUT`;
54 export PG_PASSWORD=`prepare_password $PG_PASSWORD_INPUT`;
55 export PG_ROOT_PASSWORD=`prepare_password $PG_ROOT_PASSWORD_INPUT`;
56 cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done
58 - name: PG_PRIMARY_USER
60 - name: PG_PRIMARY_PASSWORD_INPUT
61 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.primaryPasswordUID" .) "key" "password") | indent 10 }}
63 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "login") | indent 10 }}
64 - name: PG_PASSWORD_INPUT
65 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "password") | indent 10 }}
67 value: "{{ $dot.Values.config.pgDatabase }}"
68 - name: PG_ROOT_PASSWORD_INPUT
69 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.rootPassUID" .) "key" "password") | indent 10 }}
71 - mountPath: /config-input/setup.sql
76 image: "{{ $dot.Values.global.envsubstImage }}"
77 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
78 name: {{ include "common.name" $dot }}-update-config
85 chown 26:26 /podroot/;
87 image: {{ $dot.Values.global.busyboxRepository | default $dot.Values.busyboxRepository }}/{{ $dot.Values.busyboxImage }}
88 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
90 - name: {{ include "common.fullname" $dot }}-data
93 - name: {{ include "common.name" $dot }}
94 image: "{{ $dot.Values.postgresRepository }}/{{ $dot.Values.image }}"
95 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
97 - containerPort: {{ $dot.Values.service.internalPort }}
98 name: {{ $dot.Values.service.portName }}
99 # disable liveness probe when breakpoints set in debugger
100 # so K8s doesn't restart unresponsive container
101 {{- if eq $dot.Values.liveness.enabled true }}
104 port: {{ $dot.Values.service.internalPort }}
105 initialDelaySeconds: {{ $dot.Values.liveness.initialDelaySeconds }}
106 periodSeconds: {{ $dot.Values.liveness.periodSeconds }}
107 timeoutSeconds: {{ $dot.Values.liveness.timeoutSeconds }}
111 port: {{ $dot.Values.service.internalPort }}
112 initialDelaySeconds: {{ $dot.Values.readiness.initialDelaySeconds }}
113 periodSeconds: {{ $dot.Values.readiness.periodSeconds }}
117 - name: PG_PRIMARY_USER
121 - name: PG_PRIMARY_HOST
122 value: "{{ $dot.Values.container.name.primary }}"
123 - name: PG_REPLICA_HOST
124 value: "{{ $dot.Values.container.name.replica }}"
125 - name: PG_PRIMARY_PORT
126 value: "{{ $dot.Values.service.internalPort }}"
127 - name: PG_PRIMARY_PASSWORD
128 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.primaryPasswordUID" .) "key" "password") | indent 10 }}
130 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "login") | indent 10 }}
132 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "password") | indent 10 }}
134 value: "{{ $dot.Values.config.pgDatabase }}"
135 - name: PG_ROOT_PASSWORD
136 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.rootPassUID" .) "key" "password") | indent 10 }}
139 mountPath: /pgconf/pool_hba.conf
140 subPath: pool_hba.conf
142 mountPath: /pgconf/setup.sql
145 name: {{ include "common.fullname" $dot }}-data
147 name: {{ include "common.fullname" $dot }}-backup
149 resources: {{ include "common.resources" $dot | nindent 12 }}
150 {{- if $dot.Values.nodeSelector }}
152 {{ toYaml $dot.Values.nodeSelector | indent 10 }}
154 {{- if $dot.Values.affinity }}
156 {{ toYaml $dot.Values.affinity | indent 10 }}
162 - name: {{ include "common.fullname" $dot }}-backup
164 - name: {{ include "common.fullname" $dot }}-data
165 {{- if $dot.Values.persistence.enabled }}
166 persistentVolumeClaim:
167 claimName: {{ include "common.fullname" $dot }}-{{ $pgMode }}
173 name: {{ include "common.fullname" $dot }}