blob: 435c925eb22d8faa8928a05a7abb39f981870331 [file] [log] [blame]
puthuparambil.adityaf71e3652021-08-18 13:57:24 +01001{{/*
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
21apiVersion: apps/v1
22kind: StatefulSet
23metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
24spec:
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 }}
Bruno Sakotod0fa8cf2021-09-15 18:30:20 -040034 initContainers:
35 - name: chowm-mount-path
36 command:
37 - /bin/sh
38 args:
39 - -c
40 - chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.runAsGroup }} /var/lib/postgresql/data
41 image: {{ include "repositoryGenerator.image.busybox" . }}
42 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
43 volumeMounts:
44 - mountPath: /var/lib/postgresql/data
45 name: {{ include "common.fullname" . }}
puthuparambil.adityaf71e3652021-08-18 13:57:24 +010046 containers:
47 - name: {{ include "common.name" . }}
48 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
49 securityContext:
50 {{- toYaml .Values.securityContext | nindent 12 }}
51 imagePullPolicy: {{ .Values.pullPolicy }}
52 ports: {{ include "common.containerPorts" . | nindent 12 }}
53 livenessProbe:
54 exec:
55 command: ["psql", "-w", "-U", "{{ .Values.config.pgRootUserName }}", "-c", "select 1"]
56 initialDelaySeconds: 5
57 periodSeconds: 60
58 readinessProbe:
59 exec:
60 command: ["psql", "-w", "-U", "{{ .Values.config.pgRootUserName }}", "-c", "select 1"]
61 initialDelaySeconds: 5
62 periodSeconds: 30
63 env:
64 - name: DB_USERNAME
65 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "user-creds" "key" "login") | indent 14 }}
66 - name: DB_PASSWORD
67 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "user-creds" "key" "password") | indent 14 }}
68 - name: POSTGRES_DB
69 value: {{ .Values.config.pgDatabase }}
70 - name: POSTGRES_USER
71 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-creds" "key" "login") | indent 14 }}
72 - name: POSTGRES_PASSWORD
73 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-creds" "key" "password") | indent 14 }}
74 - name: PGDATA
75 value: /var/lib/postgresql/data/pgdata
76 resources:
77{{ include "common.resources" . | indent 12 }}
78 volumeMounts:
79 - name: {{ include "common.fullname" . }}-init
80 mountPath: /docker-entrypoint-initdb.d
81 - name: {{ include "common.fullname" . }}
82 mountPath: /var/lib/postgresql/data
83 volumes:
84 - name: {{ include "common.fullname" . }}-init
85 configMap:
86 name: {{ include "common.fullname" . }}-init
87 {{- with .Values.nodeSelector }}
88 nodeSelector:
89 {{- toYaml . | nindent 8 }}
90 {{- end }}
91 {{- with .Values.affinity }}
92 affinity:
93 {{- toYaml . | nindent 8 }}
94 {{- end }}
95 {{- with .Values.tolerations }}
96 tolerations:
97 {{- toYaml . | nindent 8 }}
98 {{- end }}
99 {{if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
100 volumeClaimTemplates:
101 - {{ include "common.PVCTemplate" (dict "dot" . "suffix" "data" "persistenceInfos" .Values.persistence) | indent 6 | trim }}
102{{- end }}