Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions scripts/test/kubernetes-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ kind load docker-image dbt-jaffle-shop:1.0.0
# The output is filtered to get the first pod's name
POD_NAME=$(kubectl get pods -n default -l app=postgres -o jsonpath='{.items[0].metadata.name}')

# Wait for the PostgreSQL pod to be in the 'Running' and 'Ready' state
echo "Waiting for PostgreSQL pod to be ready..."
while true; do
Comment thread
pankajkoti marked this conversation as resolved.
POD_STATUS=$(kubectl get pod "$POD_NAME" -n default -o jsonpath='{.status.phase}')

if [ "$POD_STATUS" = "Running" ] && [ "$(kubectl get pod "$POD_NAME" -n default -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}')" = "True" ]; then
echo "PostgreSQL pod is up and running!"
break
elif [ "$POD_STATUS" = "Error" ]; then
echo "Error: PostgreSQL pod failed to start. Exiting..."
kubectl describe pod "$POD_NAME" -n default # Show details for debugging
exit 1
else
echo "Pod $POD_NAME is not ready yet (status: $POD_STATUS). Waiting..."
sleep 5
fi
done
# Print the name of the PostgreSQL pod
echo "$POD_NAME"

Expand Down