Merge "Update ves collector image"
[oom.git] / kubernetes / common / postgres / templates / deployment-replica.yaml
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: Deployment
18 metadata:
19   name: {{ include "common.fullname" . }}-replica
20   namespace: {{ include "common.namespace" . }}
21   labels:
22     app: {{ include "common.name" . }}-replica
23     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
24     release: {{ include "common.release" . }}
25     heritage: {{ .Release.Service }}
26     name: "{{ .Values.container.name.replica }}"
27 spec:
28   serviceName: {{ .Values.service.name }}
29   replicas: 1
30   template:
31     metadata:
32       labels:
33         app: {{ include "common.name" . }}-replica
34         release: {{ include "common.release" . }}
35         name: "{{ .Values.container.name.replica }}"
36     spec:
37       initContainers:
38       - name: init-sysctl
39         command:
40         - /bin/sh
41         - -c
42         - |
43           chown 26:26 /podroot/;
44           chmod 700 /podroot/;
45         image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.busyboxImage }}
46         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
47         volumeMounts:
48         - name: {{ include "common.fullname" . }}-data
49           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 }}
56           name: {{ .Values.service.portName }}
57         # 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
78           value: replica
79         - 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:
105         - name: pool-hba-conf
106           mountPath: /pgconf/pool_hba.conf
107           subPath: pool_hba.conf
108         - mountPath: /pgdata
109           name: {{ include "common.fullname" . }}-data
110         - mountPath: /backup
111           name: {{ include "common.fullname" . }}-backup
112           readOnly: true
113         resources:
114 {{ include "common.resources" . | indent 12 }}
115         {{- 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
127       - name: {{ include "common.fullname" . }}-backup
128         emptyDir: {}
129       - name: {{ include "common.fullname" . }}-data
130 {{- if .Values.persistence.enabled }}
131         persistentVolumeClaim:
132             claimName: {{ include "common.fullname" . }}-replica
133 {{- else }}
134         emptyDir: {}
135 {{ end }}
136       - name: pool-hba-conf
137         configMap:
138           name: {{ include "common.fullname" . }}