blob: 57acfbda9bb221f49a79d1c5ca0b1dea581bb1ba [file] [log] [blame]
Dominic Lunanuova50aafc52018-03-30 02:29:23 +00001apiVersion: extensions/v1beta1
2kind: Deployment
3metadata:
4 name: {{ template "postgresql.fullname" . }}
5 namespace: {{ .Values.global.nsPrefix }}
6 labels:
7 app: {{ template "postgresql.fullname" . }}
8 chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
9 release: "{{ .Release.Name }}"
10 heritage: "{{ .Release.Service }}"
11spec:
12 template:
13 metadata:
14 labels:
15 app: {{ template "postgresql.fullname" . }}
16 spec:
17 {{- if .Values.affinity }}
18 affinity:
19{{ toYaml .Values.affinity | indent 8 }}
20 {{- end }}
21 {{- if .Values.nodeSelector }}
22 nodeSelector:
23{{ toYaml .Values.nodeSelector | indent 8 }}
24 {{- end }}
25 {{- if .Values.tolerations }}
26 tolerations:
27{{ toYaml .Values.tolerations | indent 8 }}
28 {{- end }}
29 {{- if .Values.schedulerName }}
30 schedulerName: "{{ .Values.schedulerName }}"
31 {{- end }}
32 containers:
33 - name: {{ template "postgresql.fullname" . }}
34 image: "{{ .Values.image }}:{{ .Values.imageTag }}"
35 imagePullPolicy: {{ default "" .Values.imagePullPolicy | quote }}
36 args:
37 {{- range $key, $value := default dict .Values.postgresConfig }}
38 - -c
39 - '{{ $key | snakecase }}={{ $value }}'
40 {{- end }}
41 env:
42 - name: POSTGRES_USER
43 value: {{ default "postgres" .Values.global.postgresUser | quote }}
44 # Required for pg_isready in the health probes.
45 - name: PGUSER
46 value: {{ default "postgres" .Values.global.postgresUser | quote }}
47 - name: POSTGRES_DB
48 value: {{ default "" .Values.global.postgresDatabase | quote }}
49 - name: POSTGRES_INITDB_ARGS
50 value: {{ default "" .Values.postgresInitdbArgs | quote }}
51 - name: PGDATA
52 value: /var/lib/postgresql/data/pgdata
53 - name: POSTGRES_PASSWORD
54 value: {{ default "postgres" .Values.global.postgresPassword | quote }}
55# original code:
56# valueFrom:
57# secretKeyRef:
58# name: {{ template "postgresql.fullname" . }}
59# key: postgres-password
60 - name: POD_IP
61 valueFrom: { fieldRef: { fieldPath: status.podIP } }
62 ports:
63 - name: postgresql
64 containerPort: 5432
65 livenessProbe:
66 exec:
67 command:
68 - sh
69 - -c
70 - exec pg_isready --host $POD_IP
71 initialDelaySeconds: 120
72 timeoutSeconds: 5
73 failureThreshold: 6
74 readinessProbe:
75 exec:
76 command:
77 - sh
78 - -c
79 - exec pg_isready --host $POD_IP
80 initialDelaySeconds: 5
81 timeoutSeconds: 3
82 periodSeconds: 5
83 resources:
84{{ toYaml .Values.resources | indent 10 }}
85 volumeMounts:
86 - name: data
87 mountPath: {{ .Values.persistence.mountPath }}
88 subPath: {{ .Values.persistence.subPath }}
89{{- if .Values.metrics.enabled }}
90 - name: metrics
91 image: "{{ .Values.metrics.image }}:{{ .Values.metrics.imageTag }}"
92 imagePullPolicy: {{ default "" .Values.metrics.imagePullPolicy | quote }}
93 env:
94 - name: DATA_SOURCE_NAME
95 value: postgresql://postgres@127.0.0.1:5432?sslmode=disable
96 ports:
97 - name: metrics
98 containerPort: 9187
99 {{- if .Values.metrics.customMetrics }}
100 args: ["-extend.query-path", "/conf/custom-metrics.yaml"]
101 volumeMounts:
102 - name: custom-metrics
103 mountPath: /conf
104 readOnly: true
105 {{- end }}
106 resources:
107{{ toYaml .Values.metrics.resources | indent 10 }}
108{{- end }}
109 volumes:
110 - name: data
111 {{- if .Values.persistence.enabled }}
112 persistentVolumeClaim:
113 claimName: {{ .Values.persistence.existingClaim | default (include "postgresql.fullname" .) }}
114 {{- else }}
115 emptyDir: {}
116 {{- end }}
117 {{- if and .Values.metrics.enabled .Values.metrics.customMetrics }}
118 - name: custom-metrics
119 secret:
120 secretName: {{ template "postgresql.fullname" . }}
121 items:
122 - key: custom-metrics.yaml
123 path: custom-metrics.yaml
124 {{- end }}
125 {{- if .Values.imagePullSecrets }}
126 imagePullSecrets:
127 - name: {{ .Values.imagePullSecrets }}
128 {{- end }}