add psql query to postgresql container liveness probe

This commit is contained in:
darteaga
2019-12-24 10:06:51 +00:00
parent a27438c43d
commit 45579c9f55
3 changed files with 23 additions and 15 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
apiVersion: v1
name: postgresql-ha
version: 1.1.2
version: 1.1.3
appVersion: 11.6.0
description: Chart for PostgreSQL with HA architecture (using Replication Manager (repmgr) and Pgpool).
keywords:
+14 -4
View File
@@ -314,18 +314,19 @@ Helm 2.11 supports the assignment of a value to a variable defined in a differen
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- $postgresqlDatabase := default "" .Values.postgresql.database -}}
{{- if .Values.global }}
{{- if .Values.global.postgresql }}
{{- if .Values.global.postgresql.database }}
{{- .Values.global.postgresql.database -}}
{{- default "" .Values.global.postgresql.database -}}
{{- else -}}
{{- .Values.postgresql.database -}}
{{- $postgresqlDatabase -}}
{{- end -}}
{{- else -}}
{{- .Values.postgresql.database -}}
{{- $postgresqlDatabase -}}
{{- end -}}
{{- else -}}
{{- .Values.postgresql.database -}}
{{- $postgresqlDatabase -}}
{{- end -}}
{{- end -}}
@@ -734,3 +735,12 @@ postgresql-ha: Upgrade repmgr extension
--set postgresql.upgradeRepmgrExtension=true
{{- end -}}
{{- end -}}
{{/* Set PGPASSWORD as environment variable depends on configuration */}}
{{- define "postgresql-ha.pgpassword" -}}
{{- if .Values.postgresql.usePasswordFile -}}
PGPASSWORD=$(cat $POSTGRES_PASSWORD_FILE)
{{- else -}}
PGPASSWORD=$POSTGRES_PASSWORD
{{- end -}}
{{- end -}}
@@ -150,11 +150,10 @@ spec:
command:
- sh
- -c
{{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }}
- exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} -h 127.0.0.1
{{- else }}
- exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -h 127.0.0.1
{{- end }}
- '{{include "postgresql-ha.pgpassword" . }} psql -w -U {{ include "postgresql-ha.postgresqlUsername" . | quote }}
{{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) -}}
-d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }}
{{- end }} -h 127.0.0.1 -c "SELECT 1"'
initialDelaySeconds: {{ .Values.postgresql.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.postgresql.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.postgresql.livenessProbe.timeoutSeconds }}
@@ -167,11 +166,10 @@ spec:
command:
- sh
- -c
{{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }}
- exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} -h 127.0.0.1
{{- else }}
- exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -h 127.0.0.1
{{- end }}
- '{{include "postgresql-ha.pgpassword" . }} psql -w -U {{ include "postgresql-ha.postgresqlUsername" . | quote }}
{{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) -}}
-d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }}
{{- end }} -h 127.0.0.1 -c "SELECT 1"'
initialDelaySeconds: {{ .Values.postgresql.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.postgresql.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.postgresql.readinessProbe.timeoutSeconds }}