Browse Source

HUE-1052 [k8s] Resolve a race between hue and pgSQL startup (#1284)

Co-authored-by: Robert Wipfel <robert.wipfel@yellowbrick.com>
Co-authored-by: Romain Rigaux <romain.rigaux@gmail.com>
Robert Wipfel 5 years ago
parent
commit
35fc44da1e

+ 14 - 0
tools/kubernetes/helm/hue/templates/deployment-hue.yaml

@@ -24,6 +24,20 @@ spec:
 {{ toYaml . | indent 8 }}
 {{ toYaml . | indent 8 }}
 {{- end }}
 {{- end }}
     spec:
     spec:
+{{ if eq .Values.hue.database.engine "postgresql_psycopg2" }}
+      initContainers:
+        - name: hue-init
+          image: {{ .Values.image.registry }}/hue:{{ .Values.image.tag }}
+          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          args:
+            - /bin/sh
+            - -c
+            - >
+              set -x;
+              while [ $(curl -s --connect-timeout 1 {{ .Values.hue.database.host }}:{{ .Values.hue.database.port }} || echo $?) -ne 52 ]; do
+                sleep 1;
+              done
+{{ end }}
       containers:
       containers:
       - name: hue
       - name: hue
         image: {{ .Values.image.registry }}/hue:{{ .Values.image.tag }}
         image: {{ .Values.image.registry }}/hue:{{ .Values.image.tag }}

+ 4 - 4
tools/kubernetes/helm/hue/templates/deployment-postgres.yaml

@@ -19,15 +19,15 @@ spec:
           image: postgres:9.5
           image: postgres:9.5
           env:
           env:
             - name: POSTGRES_USER
             - name: POSTGRES_USER
-              value: hue
+              value: {{ .Values.hue.database.user }}
             - name: POSTGRES_PASSWORD
             - name: POSTGRES_PASSWORD
-              value: hue
+              value: {{ .Values.hue.database.password }}
             - name: POSTGRES_DB
             - name: POSTGRES_DB
-              value: hue
+              value: {{ .Values.hue.database.name }}
             - name: PGDATA
             - name: PGDATA
               value: /var/lib/postgresql/data/pgdata
               value: /var/lib/postgresql/data/pgdata
           ports:
           ports:
-            - containerPort: 5432
+            - containerPort: {{ .Values.hue.database.port }}
           resources:
           resources:
             requests:
             requests:
               # memory: "350Mi"
               # memory: "350Mi"