2 # Copyright © 2018 Amdocs, AT&T, Bell Canada
3 # Copyright © 2020 Samsung Electronics
4 # Modifications Copyright (C) 2021 Bell Canada.
6 # # Licensed under the Apache License, Version 2.0 (the "License");
7 # # you may not use this file except in compliance with the License.
8 # # You may obtain a copy of the License at
10 # # http://www.apache.org/licenses/LICENSE-2.0
12 # # Unless required by applicable law or agreed to in writing, software
13 # # distributed under the License is distributed on an "AS IS" BASIS,
14 # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # # See the License for the specific language governing permissions and
16 # # limitations under the License.
19 {{- define "common.postgres.deployment" -}}
21 {{- $pgMode := .pgMode }}
25 name: {{ include "common.fullname" $dot }}-{{ $pgMode }}
26 namespace: {{ include "common.namespace" $dot }}
28 app: {{ include "common.name" $dot }}-{{ $pgMode }}
29 chart: {{ $dot.Chart.Name }}-{{ $dot.Chart.Version | replace "+" "_" }}
30 release: {{ include "common.release" $dot }}
31 heritage: {{ $dot.Release.Service }}
32 name: "{{ index $dot.Values "container" "name" $pgMode }}"
37 app: {{ include "common.name" $dot }}-{{ $pgMode }}
41 app: {{ include "common.name" $dot }}-{{ $pgMode }}
42 release: {{ include "common.release" $dot }}
43 name: "{{ index $dot.Values "container" "name" $pgMode }}"
46 - name: "{{ include "common.namespace" $dot }}-docker-registry-key"
53 function prepare_password {
54 echo -n $1 | sed -e "s/'/''/g"
56 export PG_PRIMARY_PASSWORD=`prepare_password $PG_PRIMARY_PASSWORD_INPUT`;
57 export PG_PASSWORD=`prepare_password $PG_PASSWORD_INPUT`;
58 export PG_ROOT_PASSWORD=`prepare_password $PG_ROOT_PASSWORD_INPUT`;
59 cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done
61 - name: PG_PRIMARY_USER
65 - name: PG_PRIMARY_PASSWORD_INPUT
66 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.primaryPasswordUID" .) "key" "password") | indent 10 }}
68 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "login") | indent 10 }}
69 - name: PG_PASSWORD_INPUT
70 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "password") | indent 10 }}
72 value: "{{ $dot.Values.config.pgDatabase }}"
73 - name: PG_ROOT_PASSWORD_INPUT
74 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.rootPassUID" .) "key" "password") | indent 10 }}
76 - mountPath: /config-input/setup.sql
81 image: {{ include "repositoryGenerator.image.envsubst" $dot }}
82 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
83 name: {{ include "common.name" $dot }}-update-config
90 chown 26:26 /podroot/;
92 image: {{ include "repositoryGenerator.image.busybox" $dot }}
93 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
95 - name: {{ include "common.fullname" $dot }}-data
98 - name: {{ include "common.name" $dot }}
99 image: {{ include "repositoryGenerator.image.postgres" $dot }}
100 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
102 - containerPort: {{ $dot.Values.service.internalPort }}
103 name: {{ $dot.Values.service.portName }}
104 # disable liveness probe when breakpoints set in debugger
105 # so K8s doesn't restart unresponsive container
106 {{- if eq $dot.Values.liveness.enabled true }}
109 port: {{ $dot.Values.service.internalPort }}
110 initialDelaySeconds: {{ $dot.Values.liveness.initialDelaySeconds }}
111 periodSeconds: {{ $dot.Values.liveness.periodSeconds }}
112 timeoutSeconds: {{ $dot.Values.liveness.timeoutSeconds }}
116 port: {{ $dot.Values.service.internalPort }}
117 initialDelaySeconds: {{ $dot.Values.readiness.initialDelaySeconds }}
118 periodSeconds: {{ $dot.Values.readiness.periodSeconds }}
122 - name: PG_PRIMARY_USER
128 - name: PG_PRIMARY_HOST
129 value: "{{ $dot.Values.container.name.primary }}"
130 - name: PG_REPLICA_HOST
131 value: "{{ $dot.Values.container.name.replica }}"
132 - name: PG_PRIMARY_PORT
133 value: "{{ $dot.Values.service.internalPort }}"
134 - name: PG_PRIMARY_PASSWORD
135 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.primaryPasswordUID" .) "key" "password") | indent 10 }}
137 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "login") | indent 10 }}
139 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "password") | indent 10 }}
141 value: "{{ $dot.Values.config.pgDatabase }}"
142 - name: PG_ROOT_PASSWORD
143 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.rootPassUID" .) "key" "password") | indent 10 }}
144 - name: PGDATA_PATH_OVERRIDE
145 value: "{{ $dot.Values.config.pgDataPath }}"
148 mountPath: /pgconf/pool_hba.conf
149 subPath: pool_hba.conf
151 mountPath: /pgconf/setup.sql
154 name: {{ include "common.fullname" $dot }}-data
156 name: {{ include "common.fullname" $dot }}-backup
158 resources: {{ include "common.resources" $dot | nindent 12 }}
159 {{- if $dot.Values.nodeSelector }}
161 {{ toYaml $dot.Values.nodeSelector | indent 10 }}
163 {{- if $dot.Values.affinity }}
165 {{ toYaml $dot.Values.affinity | indent 10 }}
171 - name: {{ include "common.fullname" $dot }}-backup
173 - name: {{ include "common.fullname" $dot }}-data
174 {{- if $dot.Values.persistence.enabled }}
175 persistentVolumeClaim:
176 claimName: {{ include "common.fullname" $dot }}-{{ $pgMode }}
182 name: {{ include "common.fullname" $dot }}