105 lines
3.6 KiB
YAML
105 lines
3.6 KiB
YAML
{{- if and (eq .Values.storage.mode "postgres") .Values.postgresql.enabled (not .Values.postgresql.external.enabled) }}
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "bifrost.fullname" . }}-postgresql
|
|
namespace: {{ .Release.Namespace }}
|
|
labels:
|
|
{{- include "bifrost.labels" . | nindent 4 }}
|
|
app.kubernetes.io/component: database
|
|
spec:
|
|
replicas: 1
|
|
strategy:
|
|
type: Recreate
|
|
selector:
|
|
matchLabels:
|
|
{{- include "bifrost.selectorLabels" . | nindent 6 }}
|
|
app.kubernetes.io/component: database
|
|
template:
|
|
metadata:
|
|
labels:
|
|
{{- include "bifrost.labels" . | nindent 8 }}
|
|
app.kubernetes.io/component: database
|
|
spec:
|
|
{{- with .Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.postgresql.primary.podSecurityContext }}
|
|
securityContext:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- else }}
|
|
securityContext:
|
|
fsGroup: 999
|
|
{{- end }}
|
|
containers:
|
|
- name: postgresql
|
|
image: "{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}"
|
|
imagePullPolicy: {{ .Values.postgresql.image.pullPolicy }}
|
|
{{- with .Values.postgresql.primary.containerSecurityContext }}
|
|
securityContext:
|
|
{{- toYaml . | nindent 12 }}
|
|
{{- end }}
|
|
ports:
|
|
- name: postgresql
|
|
containerPort: 5432
|
|
protocol: TCP
|
|
env:
|
|
- name: POSTGRES_USER
|
|
value: {{ .Values.postgresql.auth.username | quote }}
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ .Values.postgresql.auth.existingSecret | default (printf "%s-postgresql" (include "bifrost.fullname" .)) }}
|
|
key: {{ if .Values.postgresql.auth.existingSecret }}{{ .Values.postgresql.auth.passwordKey | default "password" }}{{ else }}password{{ end }}
|
|
- name: POSTGRES_DB
|
|
value: {{ .Values.postgresql.auth.database | quote }}
|
|
- name: PGDATA
|
|
value: /var/lib/postgresql/data/pgdata
|
|
livenessProbe:
|
|
exec:
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- pg_isready -U "{{ .Values.postgresql.auth.username }}"
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 6
|
|
readinessProbe:
|
|
exec:
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- pg_isready -U "{{ .Values.postgresql.auth.username }}"
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 6
|
|
resources:
|
|
{{- toYaml .Values.postgresql.primary.resources | nindent 12 }}
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /var/lib/postgresql/data
|
|
volumes:
|
|
- name: data
|
|
{{- if .Values.postgresql.primary.persistence.enabled }}
|
|
persistentVolumeClaim:
|
|
claimName: {{ include "bifrost.fullname" . }}-postgresql
|
|
{{- else }}
|
|
emptyDir: {}
|
|
{{- end }}
|
|
{{- with .Values.postgresql.primary.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.postgresql.primary.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.postgresql.primary.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- end }}
|