186 lines
6.4 KiB
YAML
Executable File
186 lines
6.4 KiB
YAML
Executable File
{{- $pgConfig := default dict .Values.postgresConfig -}}
|
|
{{- if .Values.backup.enabled }}
|
|
{{- $pgConfig := merge $pgConfig (default dict .Values.backup.config) -}}
|
|
{{- end -}}
|
|
|
|
apiVersion: extensions/v1beta1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ template "postgresql.fullname" . }}
|
|
labels:
|
|
app: {{ template "postgresql.name" . }}
|
|
chart: {{ template "postgresql.chart" . }}
|
|
release: {{ .Release.Name }}
|
|
heritage: {{ .Release.Service }}
|
|
{{- with .Values.deploymentAnnotations }}
|
|
annotations:
|
|
{{ toYaml . | indent 4 }}
|
|
{{- end }}
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: {{ template "postgresql.name" . }}
|
|
release: {{ .Release.Name }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: {{ template "postgresql.name" . }}
|
|
release: {{ .Release.Name }}
|
|
{{- with .Values.podAnnotations }}
|
|
annotations:
|
|
{{ toYaml . | indent 8 }}
|
|
{{- end }}
|
|
spec:
|
|
{{- if .Values.affinity }}
|
|
affinity:
|
|
{{ toYaml .Values.affinity | indent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.nodeSelector }}
|
|
nodeSelector:
|
|
{{ toYaml .Values.nodeSelector | indent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.tolerations }}
|
|
tolerations:
|
|
{{ toYaml .Values.tolerations | indent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.schedulerName }}
|
|
schedulerName: "{{ .Values.schedulerName }}"
|
|
{{- end }}
|
|
containers:
|
|
- name: {{ template "postgresql.fullname" . }}
|
|
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
|
|
imagePullPolicy: {{ default "" .Values.imagePullPolicy | quote }}
|
|
command: ["./entrypoint.sh", "postgres"]
|
|
args:
|
|
{{- range $key, $value := $pgConfig }}
|
|
- -c
|
|
- "{{ $key | snakecase }}={{ $value }}"
|
|
{{- end }}
|
|
env:
|
|
- name: POSTGRES_USER
|
|
value: {{ default "postgres" .Values.postgresUser | quote }}
|
|
# Required for pg_isready in the health probes.
|
|
- name: PGUSER
|
|
value: {{ default "postgres" .Values.postgresUser | quote }}
|
|
- name: POSTGRES_DB
|
|
value: {{ default "" .Values.postgresDatabase | quote }}
|
|
- name: POSTGRES_INITDB_ARGS
|
|
value: {{ default "" .Values.postgresInitdbArgs | quote }}
|
|
- name: PGDATA
|
|
value: /var/lib/postgresql/data/pgdata
|
|
{{- if .Values.backup.enabled }}
|
|
- name: AWS_ACCESS_KEY_ID
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ template "postgresql.secretName" . }}
|
|
key: s3-access-key
|
|
- name: AWS_SECRET_ACCESS_KEY
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ template "postgresql.secretName" . }}
|
|
key: s3-secret-key
|
|
- name: AWS_ENDPOINT
|
|
value: {{ .Values.backup.s3.endpoint | quote }}
|
|
- name: WALE_S3_PREFIX
|
|
value: {{ .Values.backup.s3.prefix | quote }}
|
|
- name: AWS_REGION
|
|
value: {{ default "us-west-2" .Values.backup.s3.region | quote }}
|
|
- name: POSTGRES_MODE
|
|
value: {{ default "backup" .Values.backup.mode }}
|
|
- name: WALG_DELETE_RETAIN
|
|
value: {{ default "15" .Values.backup.deleteRetain | quote }}
|
|
- name: WALG_BASE_BACKUP_IN
|
|
value: {{ default "0 4 * * *" .Values.backup.baseBackupIn | quote }}
|
|
{{- end -}}
|
|
{{- if .Values.usePasswordFile }}
|
|
- name: POSTGRES_PASSWORD_FILE
|
|
value: /conf/postgres-password
|
|
{{- else }}
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ template "postgresql.secretName" . }}
|
|
key: postgres-password
|
|
{{- end }}
|
|
- name: POD_IP
|
|
valueFrom: { fieldRef: { fieldPath: status.podIP } }
|
|
ports:
|
|
- name: postgresql
|
|
containerPort: 5432
|
|
livenessProbe:
|
|
exec:
|
|
command:
|
|
- sh
|
|
- -c
|
|
- exec pg_isready --host $POD_IP
|
|
initialDelaySeconds: {{ .Values.probes.liveness.initialDelay }}
|
|
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
|
|
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
|
|
readinessProbe:
|
|
exec:
|
|
command:
|
|
- sh
|
|
- -c
|
|
- exec pg_isready --host $POD_IP
|
|
initialDelaySeconds: {{ .Values.probes.readiness.initialDelay }}
|
|
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
|
|
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
|
|
resources:
|
|
{{ toYaml .Values.resources | indent 10 }}
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: {{ .Values.persistence.mountPath }}
|
|
subPath: {{ .Values.persistence.subPath }}
|
|
{{- if .Values.usePasswordFile }}
|
|
- name: password-file
|
|
mountPath: /conf
|
|
readOnly: true
|
|
{{- end }}
|
|
{{- if .Values.metrics.enabled }}
|
|
- name: metrics
|
|
image: "{{ .Values.metrics.image }}:{{ .Values.metrics.imageTag }}"
|
|
imagePullPolicy: {{ default "" .Values.metrics.imagePullPolicy | quote }}
|
|
env:
|
|
- name: DATA_SOURCE_NAME
|
|
value: postgresql://{{ default "postgres" .Values.postgresUser }}@127.0.0.1:5432?sslmode=disable
|
|
ports:
|
|
- name: metrics
|
|
containerPort: 9187
|
|
{{- if .Values.metrics.customMetrics }}
|
|
args: ["-extend.query-path", "/conf/custom-metrics.yaml"]
|
|
volumeMounts:
|
|
- name: custom-metrics
|
|
mountPath: /conf
|
|
readOnly: true
|
|
{{- end }}
|
|
resources:
|
|
{{ toYaml .Values.metrics.resources | indent 10 }}
|
|
{{- end }}
|
|
volumes:
|
|
- name: data
|
|
{{- if .Values.persistence.enabled }}
|
|
persistentVolumeClaim:
|
|
claimName: {{ .Values.persistence.existingClaim | default (include "postgresql.fullname" .) }}
|
|
{{- else }}
|
|
emptyDir: {}
|
|
{{- end }}
|
|
{{- if and .Values.metrics.enabled .Values.metrics.customMetrics }}
|
|
- name: custom-metrics
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: {{ template "postgresql.fullname" . }}
|
|
key: custom-metrics.yaml
|
|
{{- end }}
|
|
{{- if .Values.usePasswordFile }}
|
|
- name: password-file
|
|
secret:
|
|
secretName: {{ template "postgresql.secretName" . }}
|
|
items:
|
|
- key: postgres-password
|
|
path: postgres-password
|
|
{{- end }}
|
|
{{- if .Values.imagePullSecrets }}
|
|
imagePullSecrets:
|
|
- name: {{ .Values.imagePullSecrets }}
|
|
{{- end }}
|