2503bedb by Adam Heath

Add user authentication checking to pg_isready.

1 parent 1f59c12f
#!/bin/sh
set -ex
# POSTGRES_HOST
# POSTGRES_USER
# POSTGRES_DATABASE
# PGPASSWORD
check_pg() {
pg_isready -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}" -p 5432
pg_isready -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}"
}
check_auth() {
psql -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}" "${POSTGRES_DATABASE}"
}
while ! check_pg; do
echo "Waiting for database" 1>&2
loop() {
checker="$1"
message="$2"
while ! $checker; do
echo "$message" 1>&2
sleep 1
count=5
while [ $count -gt 0 ] && ! check_pg; do
while [ $count -gt 0 ] && ! $checker; do
count=$(($count - 1))
sleep 1
done
done
done
}
loop check_pg "Waiting for database to be up"
loop check_auth "Waiting for user+password to be active"
......
......@@ -113,6 +113,8 @@ releases:
- name: postgresql-scripts
mountPath: /postgresql-scripts
env:
- name: POSTGRES_DATABASE
value: moqui
- name: POSTGRES_HOST
value: {{ .Values.name }}-moqui-postgresql
- name: POSTGRES_USER
......@@ -120,6 +122,11 @@ releases:
secretKeyRef:
name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
key: username
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
key: password
{{- end }}
{{- if .Values.elasticsearch.enabled }}
- op: add
......