From b860c69fd7a7bc641ff7a2b0a7390af32b8d40f7 Mon Sep 17 00:00:00 2001 From: Dennis Zhang Date: Sat, 5 Sep 2020 19:51:58 -0700 Subject: [PATCH] Add initContainer to check for postgres up --- kubernetes/templates/deployment.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kubernetes/templates/deployment.yaml b/kubernetes/templates/deployment.yaml index eec407b0..d63747a7 100644 --- a/kubernetes/templates/deployment.yaml +++ b/kubernetes/templates/deployment.yaml @@ -23,6 +23,13 @@ spec: runAsUser: {{ .Values.securityContext.runAsUser }} runAsGroup: {{ .Values.securityContext.runAsGroup }} fsGroup: {{ .Values.securityContext.fsGroup }} + initContainers: + - name: wait-for-postgresql + image: postgres + args: + - /bin/sh + - -c + - until pg_isready -h {{ .Values.config.db.host }} -p {{ .Values.config.db.port }} -U {{ .Values.config.db.port }}; do echo waiting for database; sleep 2; done; containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"