diff --git a/deploy/k01/apply-schema.sh b/deploy/k01/apply-schema.sh index 918bc8e..9afd6ff 100755 --- a/deploy/k01/apply-schema.sh +++ b/deploy/k01/apply-schema.sh @@ -17,14 +17,18 @@ domain_dir() { psql_exec() { local cluster="$1" sql="$2" - kubectl -n juwan exec -i "${cluster}-1" -c postgres -- psql \ - -v ON_ERROR_STOP=1 -U app -d app <<<"$sql" + local pw + pw="$(kubectl -n juwan get secret "${cluster}-app" -o jsonpath='{.data.password}' | base64 -d)" + kubectl -n juwan exec -i "${cluster}-1" -c postgres -- env PGPASSWORD="$pw" \ + psql -v ON_ERROR_STOP=1 -h 127.0.0.1 -U app -d app <<<"$sql" } psql_file() { local cluster="$1" file="$2" - kubectl -n juwan exec -i "${cluster}-1" -c postgres -- psql \ - -v ON_ERROR_STOP=1 -U app -d app < "$file" + local pw + pw="$(kubectl -n juwan get secret "${cluster}-app" -o jsonpath='{.data.password}' | base64 -d)" + kubectl -n juwan exec -i "${cluster}-1" -c postgres -- env PGPASSWORD="$pw" \ + psql -v ON_ERROR_STOP=1 -h 127.0.0.1 -U app -d app < "$file" } clusters=()