From 60d89aa1651844d68df0fbed18c910deee25dc64 Mon Sep 17 00:00:00 2001 From: Tomas Pizarro Date: Wed, 5 Jun 2019 15:53:54 +0200 Subject: [PATCH] [stable/postgresql] Make readiness probe compatible for most postgresql images (#14516) * Make readiness probe compatible for most postgresql images Signed-off-by: tompizmor * Simplify logic for generating readiness probe command Signed-off-by: tompizmor --- stable/postgresql/Chart.yaml | 2 +- stable/postgresql/templates/_helpers.tpl | 15 +++++++++++++++ .../postgresql/templates/statefulset-slaves.yaml | 6 +----- stable/postgresql/templates/statefulset.yaml | 6 +----- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/stable/postgresql/Chart.yaml b/stable/postgresql/Chart.yaml index 759442df02..fd26dd2b4f 100644 --- a/stable/postgresql/Chart.yaml +++ b/stable/postgresql/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: postgresql -version: 5.3.1 +version: 5.3.2 appVersion: 11.3.0 description: Chart for PostgreSQL, an object-relational database management system (ORDBMS) with an emphasis on extensibility and on standards-compliance. keywords: diff --git a/stable/postgresql/templates/_helpers.tpl b/stable/postgresql/templates/_helpers.tpl index 40621db836..27f73c6c25 100644 --- a/stable/postgresql/templates/_helpers.tpl +++ b/stable/postgresql/templates/_helpers.tpl @@ -295,3 +295,18 @@ imagePullSecrets: {{- end }} {{- end -}} {{- end -}} + +{{/* +Get the readiness probe command +*/}} +{{- define "postgresql.readinessProbeCommand" -}} +- | +{{- if (include "postgresql.database" .) }} + pg_isready -U {{ include "postgresql.username" . | quote }} -d {{ (include "postgresql.database" .) | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }} +{{- else }} + pg_isready -U {{ include "postgresql.username" . | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }} +{{- end }} +{{- if contains "bitnami/" .Values.image.repository }} + [ -f /opt/bitnami/postgresql/tmp/.initialized ] +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/stable/postgresql/templates/statefulset-slaves.yaml b/stable/postgresql/templates/statefulset-slaves.yaml index f0cb8cb7de..9cae39425f 100644 --- a/stable/postgresql/templates/statefulset-slaves.yaml +++ b/stable/postgresql/templates/statefulset-slaves.yaml @@ -155,11 +155,7 @@ spec: command: - sh - -c - {{- if (include "postgresql.database" .) }} - - pg_isready -U {{ include "postgresql.username" . | quote }} -d {{ (include "postgresql.database" .) | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }} && [ -f /opt/bitnami/postgresql/tmp/.initialized ] - {{- else }} - - pg_isready -U {{ include "postgresql.username" . | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }} && [ -f /opt/bitnami/postgresql/tmp/.initialized ] - {{- end }} + {{- include "postgresql.readinessProbeCommand" . | nindent 12 }} initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.readinessProbe.periodSeconds }} timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} diff --git a/stable/postgresql/templates/statefulset.yaml b/stable/postgresql/templates/statefulset.yaml index 312bbaec3d..0b6003a4c1 100644 --- a/stable/postgresql/templates/statefulset.yaml +++ b/stable/postgresql/templates/statefulset.yaml @@ -180,11 +180,7 @@ spec: command: - sh - -c - {{- if (include "postgresql.database" .) }} - - pg_isready -U {{ include "postgresql.username" . | quote }} -d {{ (include "postgresql.database" .) | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }} && [ -f /opt/bitnami/postgresql/tmp/.initialized ] - {{- else }} - - pg_isready -U {{ include "postgresql.username" . | quote }} -h 127.0.0.1 -p {{ template "postgresql.port" . }} && [ -f /opt/bitnami/postgresql/tmp/.initialized ] - {{- end }} + {{- include "postgresql.readinessProbeCommand" . | nindent 12 }} initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }} periodSeconds: {{ .Values.readinessProbe.periodSeconds }} timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}