119 lines
4 KiB
YAML
119 lines
4 KiB
YAML
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: {{ include "postgresql.fullname" . }}
|
|
labels:
|
|
{{- include "postgresql.labels" . | nindent 4 }}
|
|
spec:
|
|
replicas: 1
|
|
serviceName: {{ include "postgresql.fullname" . }}-headless
|
|
selector:
|
|
matchLabels:
|
|
{{- include "postgresql.selectorLabels" . | nindent 6 }}
|
|
template:
|
|
metadata:
|
|
{{- with .Values.podAnnotations }}
|
|
annotations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
labels:
|
|
{{- include "postgresql.selectorLabels" . | nindent 8 }}
|
|
{{- with .Values.podLabels }}
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
spec:
|
|
{{- with .Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
serviceAccountName: {{ include "postgresql.serviceAccountName" . }}
|
|
securityContext:
|
|
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
|
containers:
|
|
- name: {{ .Chart.Name }}
|
|
securityContext:
|
|
{{- toYaml .Values.securityContext | nindent 12 }}
|
|
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
env:
|
|
- name: "POSTGRES_PASSWORD"
|
|
value: {{ .Values.postgres.password | quote }}
|
|
- name: "POSTGRES_USER"
|
|
value: {{ .Values.postgres.user | quote }}
|
|
- name: "PGPORT"
|
|
value: {{ .Values.service.port | quote }}
|
|
- name: "PGDATA"
|
|
value: "/var/lib/postgresql/data"
|
|
ports:
|
|
- name: postgresql
|
|
containerPort: {{ .Values.service.port }}
|
|
protocol: TCP
|
|
livenessProbe:
|
|
exec:
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- exec pg_isready -U {{ .Values.postgres.user | quote }} -h 127.0.0.1 -p {{ .Values.service.port }}
|
|
readinessProbe:
|
|
exec:
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- exec pg_isready -U {{ .Values.postgres.user | quote }} -h 127.0.0.1 -p {{ .Values.service.port }}
|
|
resources:
|
|
{{- toYaml .Values.resources | nindent 12 }}
|
|
volumeMounts:
|
|
- name: "data"
|
|
mountPath: "/var/lib/postgresql/data"
|
|
{{- with .Values.nodeSelector }}
|
|
nodeSelector:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.affinity }}
|
|
affinity:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
{{- with .Values.tolerations }}
|
|
tolerations:
|
|
{{- toYaml . | nindent 8 }}
|
|
{{- end }}
|
|
volumes:
|
|
- name: "data"
|
|
{{- if .Values.persistence.hostPath }}
|
|
hostPath:
|
|
type: Directory
|
|
path: {{ .Values.persistence.hostPath | quote }}
|
|
{{- else if .Values.persistence.enabled }}
|
|
persistentVolumeClaim:
|
|
{{ if .Values.persistence.existingClaim }}
|
|
claimName: {{ .Values.persistence.existingClaim }}
|
|
{{- else }}
|
|
claimName: {{ include "postgresql.fullname" . }}-data
|
|
{{- end }}
|
|
{{- else }}
|
|
emptyDir: {}
|
|
{{- end }}
|
|
{{- if and .Values.persistence.enabled (not .Values.persistence.hostPath) (not .Values.persistence.existingClaim) }}
|
|
volumeClaimTemplates:
|
|
- metadata:
|
|
name: data
|
|
labels:
|
|
{{- include "postgresql.labels" . | nindent 8 }}
|
|
{{- with .Values.persistence.annotations }}
|
|
annotations:
|
|
{{ toYaml . | indent 8 }}
|
|
{{- end }}
|
|
spec:
|
|
accessModes:
|
|
- {{ .Values.persistence.accessMode | quote }}
|
|
resources:
|
|
requests:
|
|
storage: {{ .Values.persistence.size | quote }}
|
|
{{- with .Values.persistence.storageClass }}
|
|
{{- if (eq "-" .) }}
|
|
storageClassName: ""
|
|
{{- else }}
|
|
storageClassName: {{ . | quote }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|