{{- if .Values.postgres.enabled -}} apiVersion: v1 kind: Service metadata: name: {{ include "tline.componentName" (dict "Values" .Values "Chart" .Chart "Release" .Release "component" "postgres") }} labels: {{ include "tline.labels" . | indent 4 }} spec: type: ClusterIP ports: - name: postgres port: {{ .Values.postgres.service.port }} targetPort: postgres selector: {{ include "tline.selectorLabels" . | indent 4 }} app.kubernetes.io/component: postgres --- apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "tline.componentName" (dict "Values" .Values "Chart" .Chart "Release" .Release "component" "postgres") }} labels: {{ include "tline.labels" . | indent 4 }} app.kubernetes.io/component: postgres spec: serviceName: {{ include "tline.componentName" (dict "Values" .Values "Chart" .Chart "Release" .Release "component" "postgres") }} replicas: 1 selector: matchLabels: {{ include "tline.selectorLabels" . | indent 6 }} app.kubernetes.io/component: postgres template: metadata: labels: {{ include "tline.selectorLabels" . | indent 8 }} app.kubernetes.io/component: postgres spec: {{ include "tline.imagePullSecrets" . | indent 6 }} {{- $aff := include "tline.affinity" (dict "Values" .Values "schedulingClass" .Values.postgres.schedulingClass) }} {{- if $aff }} affinity: {{ $aff | indent 8 }} {{- end }} {{- $tols := include "tline.tolerations" (dict "Values" .Values "schedulingClass" .Values.postgres.schedulingClass) }} {{- if $tols }} tolerations: {{ $tols | indent 8 }} {{- end }} containers: - name: postgres image: {{ printf "%s:%s" .Values.images.postgres.repository .Values.images.postgres.tag | quote }} imagePullPolicy: {{ .Values.images.postgres.pullPolicy }} ports: - name: postgres containerPort: 5432 env: - name: POSTGRES_USER value: {{ .Values.secrets.postgres.user | quote }} - name: POSTGRES_DB value: {{ .Values.secrets.postgres.database | quote }} - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: {{ include "tline.secretName" . }} key: POSTGRES_PASSWORD readinessProbe: exec: command: - sh - -c - pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB" initialDelaySeconds: 5 periodSeconds: 5 livenessProbe: exec: command: - sh - -c - pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB" initialDelaySeconds: 20 periodSeconds: 10 resources: {{ toYaml .Values.postgres.resources | indent 12 }} volumeMounts: - name: data mountPath: /var/lib/postgresql/data volumeClaimTemplates: - metadata: name: data spec: accessModes: - ReadWriteOnce {{- $sc := include "tline.storageClass" (dict "Values" .Values "storageClass" .Values.postgres.storage.storageClass) -}} {{- if $sc }} storageClassName: {{ $sc | quote }} {{- end }} resources: requests: storage: {{ .Values.postgres.storage.size | quote }} {{- end }}