This commit is contained in:
@@ -50,6 +50,23 @@ trap cleanup EXIT
|
|||||||
trap 'exit 130' INT
|
trap 'exit 130' INT
|
||||||
trap 'exit 143' TERM
|
trap 'exit 143' TERM
|
||||||
|
|
||||||
|
wait_for_pod() {
|
||||||
|
local selector
|
||||||
|
# Use the service's selector rather than assuming a particular pod label.
|
||||||
|
if ! selector=$(kubectl -n sejs get svc btcdata --request-timeout=10s \
|
||||||
|
-o go-template='{{range $key, $value := .spec.selector}}{{$key}}={{$value}},{{end}}'); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
selector=${selector%,}
|
||||||
|
if [[ -z $selector ]]; then
|
||||||
|
echo "Service sejs/btcdata has no pod selector." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
echo "Waiting up to 5 minutes for btcdata pods to become Ready..." >&2
|
||||||
|
kubectl -n sejs wait --for=condition=Ready pod --selector="$selector" \
|
||||||
|
--timeout=300s --request-timeout=310s >&2
|
||||||
|
}
|
||||||
|
|
||||||
start_forward() {
|
start_forward() {
|
||||||
local attempt
|
local attempt
|
||||||
cleanup
|
cleanup
|
||||||
@@ -57,6 +74,10 @@ start_forward() {
|
|||||||
echo "Service unavailable on localhost:4101 and kubectl is not installed." >&2
|
echo "Service unavailable on localhost:4101 and kubectl is not installed." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
if ! wait_for_pod; then
|
||||||
|
echo "btcdata pod readiness check failed; not opening a tunnel." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
echo "Starting kubectl port-forward for sejs/btcdata..." >&2
|
echo "Starting kubectl port-forward for sejs/btcdata..." >&2
|
||||||
kubectl -n sejs port-forward svc/btcdata 4101:4101 >&2 &
|
kubectl -n sejs port-forward svc/btcdata 4101:4101 >&2 &
|
||||||
forward_pid=$!
|
forward_pid=$!
|
||||||
|
|||||||
Reference in New Issue
Block a user