puthuparambil.aditya | f71e365 | 2021-08-18 13:57:24 +0100 | [diff] [blame^] | 1 | {{/* |
| 2 | # ============LICENSE_START======================================================= |
| 3 | # Copyright (c) 2021 Bell Canada. |
| 4 | # ================================================================================ |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | # SPDX-License-Identifier: Apache-2.0 |
| 18 | # ============LICENSE_END========================================================= |
| 19 | */}} |
| 20 | |
| 21 | apiVersion: apps/v1 |
| 22 | kind: StatefulSet |
| 23 | metadata: {{- include "common.resourceMetadata" . | nindent 2 }} |
| 24 | spec: |
| 25 | replicas: {{ .Values.replicaCount }} |
| 26 | selector: {{- include "common.selectors" . | nindent 4 }} |
| 27 | serviceName: {{ include "common.servicename" . }} |
| 28 | template: |
| 29 | metadata: {{- include "common.templateMetadata" . | nindent 6 }} |
| 30 | spec: |
| 31 | serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . ) }} |
| 32 | securityContext: |
| 33 | {{- toYaml .Values.podSecurityContext | nindent 8 }} |
| 34 | containers: |
| 35 | - name: {{ include "common.name" . }} |
| 36 | image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }} |
| 37 | securityContext: |
| 38 | {{- toYaml .Values.securityContext | nindent 12 }} |
| 39 | imagePullPolicy: {{ .Values.pullPolicy }} |
| 40 | ports: {{ include "common.containerPorts" . | nindent 12 }} |
| 41 | livenessProbe: |
| 42 | exec: |
| 43 | command: ["psql", "-w", "-U", "{{ .Values.config.pgRootUserName }}", "-c", "select 1"] |
| 44 | initialDelaySeconds: 5 |
| 45 | periodSeconds: 60 |
| 46 | readinessProbe: |
| 47 | exec: |
| 48 | command: ["psql", "-w", "-U", "{{ .Values.config.pgRootUserName }}", "-c", "select 1"] |
| 49 | initialDelaySeconds: 5 |
| 50 | periodSeconds: 30 |
| 51 | env: |
| 52 | - name: DB_USERNAME |
| 53 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "user-creds" "key" "login") | indent 14 }} |
| 54 | - name: DB_PASSWORD |
| 55 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "user-creds" "key" "password") | indent 14 }} |
| 56 | - name: POSTGRES_DB |
| 57 | value: {{ .Values.config.pgDatabase }} |
| 58 | - name: POSTGRES_USER |
| 59 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-creds" "key" "login") | indent 14 }} |
| 60 | - name: POSTGRES_PASSWORD |
| 61 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-creds" "key" "password") | indent 14 }} |
| 62 | - name: PGDATA |
| 63 | value: /var/lib/postgresql/data/pgdata |
| 64 | resources: |
| 65 | {{ include "common.resources" . | indent 12 }} |
| 66 | volumeMounts: |
| 67 | - name: {{ include "common.fullname" . }}-init |
| 68 | mountPath: /docker-entrypoint-initdb.d |
| 69 | - name: {{ include "common.fullname" . }} |
| 70 | mountPath: /var/lib/postgresql/data |
| 71 | volumes: |
| 72 | - name: {{ include "common.fullname" . }}-init |
| 73 | configMap: |
| 74 | name: {{ include "common.fullname" . }}-init |
| 75 | {{- with .Values.nodeSelector }} |
| 76 | nodeSelector: |
| 77 | {{- toYaml . | nindent 8 }} |
| 78 | {{- end }} |
| 79 | {{- with .Values.affinity }} |
| 80 | affinity: |
| 81 | {{- toYaml . | nindent 8 }} |
| 82 | {{- end }} |
| 83 | {{- with .Values.tolerations }} |
| 84 | tolerations: |
| 85 | {{- toYaml . | nindent 8 }} |
| 86 | {{- end }} |
| 87 | {{if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} |
| 88 | volumeClaimTemplates: |
| 89 | - {{ include "common.PVCTemplate" (dict "dot" . "suffix" "data" "persistenceInfos" .Values.persistence) | indent 6 | trim }} |
| 90 | {{- end }} |