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
31 changes: 29 additions & 2 deletions scripts/install.tpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,40 @@ function kubectl_wait_rollout() {
kubectl rollout status --namespace="${namespace}" "${runtime}" --timeout="${timeout}"
}

function kubectl_wait_for_query() {
manifest=$1
query=$2
timeout=$3
poll_interval_in_seconds=$4

if [[ -z "$manifest" || -z "$query" || -z "$timeout" || -z "$poll_interval_in_seconds" ]]; then
echo "Error: Missing arguments."
echo "Usage: kubectl_wait_for_query <manifest> <query> <timeout> <poll_interval_in_seconds>"
exit 1
fi

start_time=$(date +%s)
while true; do
val=$(kubectl get "${manifest}" -o jsonpath="${query}" 2>/dev/null || echo "")
if [[ -n "${val}" ]]; then
echo "${manifest} has ${query}."
break
fi
if [[ $(( $(date +%s) - start_time )) -ge ${timeout} ]]; then
echo "Timed out waiting for ${manifest} to have ${query}."
exit 1
fi
sleep ${poll_interval_in_seconds}s
done
}

kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/${cert_mgr_version}/cert-manager.yaml"
# Wait for cert-manager to be fully ready
kubectl_wait "cert-manager" "deployment/cert-manager-webhook" "60s"
kubectl_wait "cert-manager" "deployment/cert-manager-cainjector" "60s"
kubectl_wait "cert-manager" "deployment/cert-manager" "60s"
kubectl wait mutatingwebhookconfigurations/cert-manager-webhook --for=jsonpath='{.webhooks[0].clientConfig.caBundle}' --timeout=60s
kubectl wait validatingwebhookconfigurations/cert-manager-webhook --for=jsonpath='{.webhooks[0].clientConfig.caBundle}' --timeout=60s
kubectl_wait_for_query "mutatingwebhookconfigurations/cert-manager-webhook" '{.webhooks[0].clientConfig.caBundle}' 60 5
kubectl_wait_for_query "validatingwebhookconfigurations/cert-manager-webhook" '{.webhooks[0].clientConfig.caBundle}' 60 5

kubectl apply -f "https://github.com/operator-framework/catalogd/releases/download/${catalogd_version}/catalogd.yaml"
# Wait for the rollout, and then wait for the deployment to be Available
Expand Down