puthuparambil.aditya | f71e365 | 2021-08-18 13:57:24 +0100 | [diff] [blame] | 1 | {{/* |
| 2 | # ============LICENSE_START======================================================= |
Bruno Sakoto | 79a0a14 | 2022-04-08 06:27:06 -0400 | [diff] [blame] | 3 | # Copyright (c) 2021-2022 Bell Canada. |
puthuparambil.aditya | f71e365 | 2021-08-18 13:57:24 +0100 | [diff] [blame] | 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: |
Bruno Sakoto | 79a0a14 | 2022-04-08 06:27:06 -0400 | [diff] [blame] | 29 | metadata: {{- include "common.templateMetadata" (dict "ignoreHelmChart" true "dot" . ) | nindent 6 }} |
puthuparambil.aditya | f71e365 | 2021-08-18 13:57:24 +0100 | [diff] [blame] | 30 | spec: |
| 31 | serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . ) }} |
Renu Kumari | bc6eede | 2021-10-08 13:03:10 -0400 | [diff] [blame] | 32 | {{ include "common.podSecurityContext" . | indent 10 | trim}} |
Renu Kumari | 3507fdc | 2021-10-13 10:51:53 -0400 | [diff] [blame] | 33 | initContainers: |
| 34 | # we shouldn't need this but for unknown reason, it's fsGroup is not |
| 35 | # applied |
| 36 | - name: fix-permission |
| 37 | command: |
| 38 | - /bin/sh |
| 39 | args: |
| 40 | - -c |
| 41 | - chown -R {{ .Values.securityContext.user_id }}:{{ .Values.securityContext.group_id }} /var/lib/postgresql/data |
| 42 | image: {{ include "repositoryGenerator.image.busybox" . }} |
| 43 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 44 | securityContext: |
| 45 | runAsUser: 0 |
| 46 | volumeMounts: |
| 47 | - mountPath: /var/lib/postgresql/data |
| 48 | name: {{ include "common.fullname" . }} |
puthuparambil.aditya | f71e365 | 2021-08-18 13:57:24 +0100 | [diff] [blame] | 49 | containers: |
| 50 | - name: {{ include "common.name" . }} |
| 51 | image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }} |
puthuparambil.aditya | f71e365 | 2021-08-18 13:57:24 +0100 | [diff] [blame] | 52 | imagePullPolicy: {{ .Values.pullPolicy }} |
| 53 | ports: {{ include "common.containerPorts" . | nindent 12 }} |
| 54 | livenessProbe: |
| 55 | exec: |
| 56 | command: ["psql", "-w", "-U", "{{ .Values.config.pgRootUserName }}", "-c", "select 1"] |
| 57 | initialDelaySeconds: 5 |
| 58 | periodSeconds: 60 |
| 59 | readinessProbe: |
| 60 | exec: |
| 61 | command: ["psql", "-w", "-U", "{{ .Values.config.pgRootUserName }}", "-c", "select 1"] |
| 62 | initialDelaySeconds: 5 |
| 63 | periodSeconds: 30 |
| 64 | env: |
| 65 | - name: DB_USERNAME |
| 66 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "user-creds" "key" "login") | indent 14 }} |
| 67 | - name: DB_PASSWORD |
| 68 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "user-creds" "key" "password") | indent 14 }} |
| 69 | - name: POSTGRES_DB |
| 70 | value: {{ .Values.config.pgDatabase }} |
| 71 | - name: POSTGRES_USER |
| 72 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-creds" "key" "login") | indent 14 }} |
| 73 | - name: POSTGRES_PASSWORD |
| 74 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-creds" "key" "password") | indent 14 }} |
| 75 | - name: PGDATA |
| 76 | value: /var/lib/postgresql/data/pgdata |
| 77 | resources: |
| 78 | {{ include "common.resources" . | indent 12 }} |
| 79 | volumeMounts: |
| 80 | - name: {{ include "common.fullname" . }}-init |
| 81 | mountPath: /docker-entrypoint-initdb.d |
| 82 | - name: {{ include "common.fullname" . }} |
| 83 | mountPath: /var/lib/postgresql/data |
| 84 | volumes: |
| 85 | - name: {{ include "common.fullname" . }}-init |
| 86 | configMap: |
| 87 | name: {{ include "common.fullname" . }}-init |
| 88 | {{- with .Values.nodeSelector }} |
| 89 | nodeSelector: |
| 90 | {{- toYaml . | nindent 8 }} |
| 91 | {{- end }} |
| 92 | {{- with .Values.affinity }} |
| 93 | affinity: |
| 94 | {{- toYaml . | nindent 8 }} |
| 95 | {{- end }} |
| 96 | {{- with .Values.tolerations }} |
| 97 | tolerations: |
| 98 | {{- toYaml . | nindent 8 }} |
| 99 | {{- end }} |
| 100 | {{if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} |
| 101 | volumeClaimTemplates: |
Bruno Sakoto | 79a0a14 | 2022-04-08 06:27:06 -0400 | [diff] [blame] | 102 | - {{ include "common.PVCTemplate" (dict "dot" . "suffix" "data" "persistenceInfos" .Values.persistence "ignoreHelmChart" true) | indent 6 | trim }} |
puthuparambil.aditya | f71e365 | 2021-08-18 13:57:24 +0100 | [diff] [blame] | 103 | {{- end }} |