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 |
| 17 | kind: StatefulSet |
| 18 | metadata: |
| 19 | name: {{ include "common.fullname" . }} |
| 20 | namespace: {{ include "common.namespace" . }} |
| 21 | labels: |
| 22 | app: {{ include "common.name" . }} |
| 23 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} |
| 24 | release: {{ .Release.Name }} |
| 25 | heritage: {{ .Release.Service }} |
| 26 | spec: |
| 27 | serviceName: {{ .Values.service.name }} |
| 28 | replicas: {{ .Values.replicaCount }} |
| 29 | template: |
| 30 | metadata: |
| 31 | labels: |
| 32 | app: {{ include "common.name" . }} |
| 33 | release: {{ .Release.Name }} |
| 34 | spec: |
| 35 | initContainers: |
| 36 | - command: |
| 37 | - /bin/sh |
| 38 | - -c |
| 39 | - | |
| 40 | for i in $(seq 0 $(({{ .Values.replicaCount }}-1))); do mkdir -p /podroot/data$i; done |
| 41 | chmod 777 /podroot/* |
| 42 | env: |
| 43 | - name: POD_NAME |
| 44 | valueFrom: { fieldRef: { fieldPath: metadata.name } } |
| 45 | securityContext: |
| 46 | privileged: true |
| 47 | image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.busyboxImage }} |
| 48 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 49 | name: init-sysctl |
| 50 | volumeMounts: |
| 51 | - name: {{ include "common.fullname" . }}-init |
| 52 | mountPath: /podroot/ |
| 53 | containers: |
| 54 | - name: {{ include "common.name" . }} |
| 55 | image: "{{ .Values.postgresRepository }}/{{ .Values.image }}" |
| 56 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 57 | ports: |
| 58 | - containerPort: {{ .Values.service.internalPort }} |
| 59 | name: postgres |
| 60 | # disable liveness probe when breakpoints set in debugger |
| 61 | # so K8s doesn't restart unresponsive container |
| 62 | {{- if eq .Values.liveness.enabled true }} |
| 63 | livenessProbe: |
| 64 | tcpSocket: |
| 65 | port: {{ .Values.service.internalPort }} |
| 66 | initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} |
| 67 | periodSeconds: {{ .Values.liveness.periodSeconds }} |
| 68 | timeoutSeconds: {{ .Values.liveness.timeoutSeconds }} |
| 69 | {{end -}} |
| 70 | readinessProbe: |
| 71 | tcpSocket: |
| 72 | port: {{ .Values.service.internalPort }} |
| 73 | initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} |
| 74 | periodSeconds: {{ .Values.readiness.periodSeconds }} |
| 75 | env: |
| 76 | - name: PGHOST |
| 77 | value: /tmp |
| 78 | - name: PG_PRIMARY_USER |
| 79 | value: primaryuser |
| 80 | - name: PG_MODE |
| 81 | value: set |
| 82 | - name: PG_PRIMARY_HOST |
| 83 | value: "{{.Values.container.name.primary}}" |
| 84 | - name: PG_REPLICA_HOST |
| 85 | value: "{{.Values.container.name.replica}}" |
| 86 | - name: PG_PRIMARY_PORT |
| 87 | value: "{{.Values.service.internalPort}}" |
| 88 | - name: PG_PRIMARY_PASSWORD |
| 89 | valueFrom: |
| 90 | secretKeyRef: |
| 91 | name: {{ template "common.fullname" . }} |
| 92 | key: pg-primary-password |
| 93 | - name: PG_USER |
| 94 | value: "{{.Values.config.pgUserName}}" |
| 95 | - name: PG_PASSWORD |
| 96 | valueFrom: |
| 97 | secretKeyRef: |
| 98 | name: {{ template "common.fullname" . }} |
| 99 | key: pg-user-password |
| 100 | - name: PG_DATABASE |
| 101 | value: "{{.Values.config.pgDatabase}}" |
| 102 | - name: PG_ROOT_PASSWORD |
| 103 | valueFrom: |
| 104 | secretKeyRef: |
| 105 | name: {{ template "common.fullname" . }} |
| 106 | key: pg-root-password |
| 107 | volumeMounts: |
| 108 | - mountPath: /pgdata |
| 109 | name: {{ include "common.fullname" . }}-data |
| 110 | - mountPath: /backup |
| 111 | name: {{ include "common.fullname" . }}-backup |
| 112 | readOnly: true |
| 113 | resources: |
| 114 | {{ toYaml .Values.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" . }}-init |
| 128 | hostPath: |
BorislavG | 56857c4 | 2018-05-03 14:29:51 +0000 | [diff] [blame] | 129 | path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountInitPath }} |
BorislavG | b36d86c | 2018-04-01 18:59:54 +0300 | [diff] [blame] | 130 | - name: {{ include "common.fullname" . }}-backup |
| 131 | emptyDir: {} |
| 132 | #{{ if not .Values.persistence.enabled }} |
| 133 | - name: {{ include "common.fullname" . }}-data |
| 134 | emptyDir: {} |
| 135 | #{{ else }} |
| 136 | volumeClaimTemplates: |
| 137 | - metadata: |
| 138 | name: {{ include "common.fullname" . }}-data |
| 139 | labels: |
| 140 | name: {{ include "common.fullname" . }} |
| 141 | spec: |
| 142 | accessModes: [ {{ .Values.persistence.accessMode }} ] |
| 143 | storageClassName: {{ include "common.fullname" . }}-data |
| 144 | resources: |
| 145 | requests: |
| 146 | storage: {{ .Values.persistence.size }} |
| 147 | #{{ end }} |