BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 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 |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 17 | kind: Deployment |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 18 | metadata: |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 19 | name: {{ include "common.fullname" . }}-replica |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 20 | namespace: {{ include "common.namespace" . }} |
| 21 | labels: |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 22 | app: {{ include "common.name" . }}-replica |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 23 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame^] | 24 | release: {{ include "common.release" . }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 25 | heritage: {{ .Release.Service }} |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 26 | name: "{{ .Values.container.name.replica }}" |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 27 | spec: |
| 28 | serviceName: {{ .Values.service.name }} |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 29 | replicas: 1 |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 30 | template: |
| 31 | metadata: |
| 32 | labels: |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 33 | app: {{ include "common.name" . }}-replica |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame^] | 34 | release: {{ include "common.release" . }} |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 35 | name: "{{ .Values.container.name.replica }}" |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 36 | spec: |
| 37 | initContainers: |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 38 | - name: init-sysctl |
| 39 | command: |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 40 | - /bin/sh |
| 41 | - -c |
| 42 | - | |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 43 | chown 26:26 /podroot/; |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 44 | chmod 700 /podroot/; |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 45 | image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.busyboxImage }} |
| 46 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 47 | volumeMounts: |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 48 | - name: {{ include "common.fullname" . }}-data |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 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 }} |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 56 | name: {{ .Values.service.portName }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 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 |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 78 | value: replica |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 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: |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 105 | - name: pool-hba-conf |
| 106 | mountPath: /pgconf/pool_hba.conf |
| 107 | subPath: pool_hba.conf |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 108 | - mountPath: /pgdata |
| 109 | name: {{ include "common.fullname" . }}-data |
| 110 | - mountPath: /backup |
| 111 | name: {{ include "common.fullname" . }}-backup |
| 112 | readOnly: true |
| 113 | resources: |
Mandeep Khinda | 5e3f36a | 2018-09-24 15:25:42 +0000 | [diff] [blame] | 114 | {{ include "common.resources" . | indent 12 }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 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 |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 127 | - name: {{ include "common.fullname" . }}-backup |
| 128 | emptyDir: {} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 129 | - name: {{ include "common.fullname" . }}-data |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 130 | {{- if .Values.persistence.enabled }} |
| 131 | persistentVolumeClaim: |
| 132 | claimName: {{ include "common.fullname" . }}-replica |
Sylvain Desbureaux | b7ed2ee | 2019-11-29 11:35:13 +0100 | [diff] [blame] | 133 | {{- else }} |
Sylvain Desbureaux | 0b243b6 | 2019-12-11 11:53:42 +0100 | [diff] [blame] | 134 | emptyDir: {} |
| 135 | {{ end }} |
| 136 | - name: pool-hba-conf |
| 137 | configMap: |
| 138 | name: {{ include "common.fullname" . }} |