prole/tmp/poll_ready.sh

33 lines
1.2 KiB
Bash

#!/usr/bin/env bash
export KUBECONFIG=/Users/chrisfu/dev/knoe/knoe-k3s.kubeconfig
for i in $(seq 1 20); do
ws_ready=$(kubectl -n gitea get pods -l app=webservice \
-o jsonpath='{range .items[*]}{.status.containerStatuses[?(@.name=="webservice")].ready}{"\n"}{end}' \
2>/dev/null | grep -c "^true$" || echo 0)
sk_ready=$(kubectl -n gitea get pod -l app=sidekiq \
-o jsonpath='{.items[0].status.containerStatuses[0].ready}' 2>/dev/null || echo false)
phase=$(kubectl -n gitea get gitlab gitlab \
-o jsonpath='{.status.phase}' 2>/dev/null || echo "unknown")
echo "[$(date -u '+%H:%M:%S')] [$i/20] webservice puma ready: $ws_ready | sidekiq ready: $sk_ready | CR: $phase"
if [[ "$ws_ready" -ge 1 && "$sk_ready" == "true" ]]; then
echo "==> GitLab is fully up!"
break
fi
sleep 90
done
echo "==> Final pod status:"
kubectl -n gitea get pods --no-headers \
| grep -v jemalloc | grep -v Completed | sort
echo "==> CR conditions:"
kubectl -n gitea get gitlab gitlab \
-o jsonpath='{range .status.conditions[*]}{.type}: {.status} ({.message}){"\n"}{end}' 2>&1
echo "==> Initial root password:"
kubectl -n gitea get secret gitlab-gitlab-initial-root-password \
-o jsonpath='{.data.password}' 2>/dev/null | base64 -d && echo || true