blob: 9cb3007400f761750e8104076f9a1f94d185568f [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" . }}-primary
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" . }}-primary
BorislavGb36d86c2018-04-01 18:59:54 +030023 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
24 release: {{ .Release.Name }}
25 heritage: {{ .Release.Service }}
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010026 name: "{{ .Values.container.name.primary }}"
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" . }}-primary
BorislavGb36d86c2018-04-01 18:59:54 +030034 release: {{ .Release.Name }}
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010035 name: "{{ .Values.container.name.primary }}"
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 }}
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010066 {{- end }}
BorislavGb36d86c2018-04-01 18:59:54 +030067 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: primary
BorislavGb36d86c2018-04-01 18:59:54 +030079 - name: PG_PRIMARY_HOST
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010080 value: "{{ .Values.container.name.primary }}"
BorislavGb36d86c2018-04-01 18:59:54 +030081 - name: PG_REPLICA_HOST
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010082 value: "{{ .Values.container.name.replica }}"
BorislavGb36d86c2018-04-01 18:59:54 +030083 - name: PG_PRIMARY_PORT
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010084 value: "{{ .Values.service.internalPort }}"
BorislavGb36d86c2018-04-01 18:59:54 +030085 - name: PG_PRIMARY_PASSWORD
86 valueFrom:
87 secretKeyRef:
88 name: {{ template "common.fullname" . }}
89 key: pg-primary-password
90 - name: PG_USER
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010091 value: "{{ .Values.config.pgUserName }}"
BorislavGb36d86c2018-04-01 18:59:54 +030092 - name: PG_PASSWORD
93 valueFrom:
94 secretKeyRef:
95 name: {{ template "common.fullname" . }}
96 key: pg-user-password
97 - name: PG_DATABASE
Sylvain Desbureaux0b243b62019-12-11 11:53:42 +010098 value: "{{ .Values.config.pgDatabase }}"
BorislavGb36d86c2018-04-01 18:59:54 +030099 - 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" . }}-primary
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" . }}