2 # Copyright © 2018 Amdocs, AT&T, Bell Canada
3 # Copyright © 2020 Samsung Electronics
4 # Copyright © 2021 Orange
5 # Modifications Copyright (C) 2021 Bell Canada.
7 # # Licensed under the Apache License, Version 2.0 (the "License");
8 # # you may not use this file except in compliance with the License.
9 # # You may obtain a copy of the License at
11 # # http://www.apache.org/licenses/LICENSE-2.0
13 # # Unless required by applicable law or agreed to in writing, software
14 # # distributed under the License is distributed on an "AS IS" BASIS,
15 # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # # See the License for the specific language governing permissions and
17 # # limitations under the License.
20 {{- define "common.postgres.deployment" -}}
22 {{- $pgMode := .pgMode }}
26 name: {{ include "common.fullname" $dot }}-{{ $pgMode }}
27 namespace: {{ include "common.namespace" $dot }}
29 app: {{ include "common.name" $dot }}-{{ $pgMode }}
30 chart: {{ $dot.Chart.Name }}-{{ $dot.Chart.Version | replace "+" "_" }}
31 release: {{ include "common.release" $dot }}
32 heritage: {{ $dot.Release.Service }}
33 name: "{{ index $dot.Values "container" "name" $pgMode }}"
38 app: {{ include "common.name" $dot }}-{{ $pgMode }}
42 app: {{ include "common.name" $dot }}-{{ $pgMode }}
43 release: {{ include "common.release" $dot }}
44 name: "{{ index $dot.Values "container" "name" $pgMode }}"
47 - name: "{{ include "common.namespace" $dot }}-docker-registry-key"
54 function prepare_password {
55 echo -n $1 | sed -e "s/'/''/g"
57 export PG_PRIMARY_PASSWORD=`prepare_password $PG_PRIMARY_PASSWORD_INPUT`;
58 export PG_PASSWORD=`prepare_password $PG_PASSWORD_INPUT`;
59 export PG_ROOT_PASSWORD=`prepare_password $PG_ROOT_PASSWORD_INPUT`;
60 cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done
62 - name: PG_PRIMARY_USER
66 - name: PG_PRIMARY_PASSWORD_INPUT
67 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.primaryPasswordUID" .) "key" "password") | indent 10 }}
69 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "login") | indent 10 }}
70 - name: PG_PASSWORD_INPUT
71 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "password") | indent 10 }}
73 value: "{{ $dot.Values.config.pgDatabase }}"
74 - name: PG_ROOT_PASSWORD_INPUT
75 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.rootPassUID" .) "key" "password") | indent 10 }}
77 - mountPath: /config-input/setup.sql
82 image: {{ include "repositoryGenerator.image.envsubst" $dot }}
83 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
84 name: {{ include "common.name" $dot }}-update-config
91 chown 26:26 /podroot/;
93 image: {{ include "repositoryGenerator.image.busybox" $dot }}
94 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
96 - name: {{ include "common.fullname" $dot }}-data
99 - name: {{ include "common.name" $dot }}
100 image: {{ include "repositoryGenerator.image.postgres" $dot }}
101 imagePullPolicy: {{ $dot.Values.global.pullPolicy | default $dot.Values.pullPolicy }}
103 - containerPort: {{ $dot.Values.service.internalPort }}
104 name: {{ $dot.Values.service.portName }}
105 # disable liveness probe when breakpoints set in debugger
106 # so K8s doesn't restart unresponsive container
107 {{- if eq $dot.Values.liveness.enabled true }}
110 port: {{ $dot.Values.service.internalPort }}
111 initialDelaySeconds: {{ $dot.Values.liveness.initialDelaySeconds }}
112 periodSeconds: {{ $dot.Values.liveness.periodSeconds }}
113 timeoutSeconds: {{ $dot.Values.liveness.timeoutSeconds }}
117 port: {{ $dot.Values.service.internalPort }}
118 initialDelaySeconds: {{ $dot.Values.readiness.initialDelaySeconds }}
119 periodSeconds: {{ $dot.Values.readiness.periodSeconds }}
123 - name: PG_PRIMARY_USER
129 - name: PG_PRIMARY_HOST
130 value: "{{ $dot.Values.service.name2 }}"
131 - name: PG_REPLICA_HOST
132 value: "{{ $dot.Values.service.name3 }}"
133 - name: PG_PRIMARY_PORT
134 value: "{{ $dot.Values.service.internalPort }}"
135 - name: PG_PRIMARY_PASSWORD
136 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.primaryPasswordUID" .) "key" "password") | indent 10 }}
138 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "login") | indent 10 }}
140 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "password") | indent 10 }}
142 value: "{{ $dot.Values.config.pgDatabase }}"
143 - name: PG_ROOT_PASSWORD
144 {{- include "common.secret.envFromSecretFast" (dict "global" $dot "uid" (include "common.postgres.secret.rootPassUID" .) "key" "password") | indent 10 }}
145 - name: PGDATA_PATH_OVERRIDE
146 value: "{{ $dot.Values.config.pgDataPath }}"
149 mountPath: /pgconf/pool_hba.conf
150 subPath: pool_hba.conf
152 mountPath: /pgconf/setup.sql
155 name: {{ include "common.fullname" $dot }}-data
157 name: {{ include "common.fullname" $dot }}-backup
159 resources: {{ include "common.resources" $dot | nindent 12 }}
160 {{- if $dot.Values.nodeSelector }}
162 {{ toYaml $dot.Values.nodeSelector | indent 10 }}
164 {{- if $dot.Values.affinity }}
166 {{ toYaml $dot.Values.affinity | indent 10 }}
172 - name: {{ include "common.fullname" $dot }}-backup
174 - name: {{ include "common.fullname" $dot }}-data
175 {{- if $dot.Values.persistence.enabled }}
176 persistentVolumeClaim:
177 claimName: {{ include "common.fullname" $dot }}-{{ $pgMode }}
183 name: {{ include "common.fullname" $dot }}