Skip to content

Commit 514d318

Browse files
fix: add kubectl_wait_for_caBundle to handle caBundle readiness checks
- Added `kubectl_wait_for_caBundle` function to independently check if `caBundle` is populated in webhook configurations. - Resolves error: `jsonpath wait format must be --for=jsonpath='{.status.readyReplicas}'=3`, which occurs because the script initially assumes 3 ready replicas for cert-manager deployments. This assumption is inaccurate for development purposes and for users following the getting started documentation where cert-manager is installed using the `install.sh` script from releases.
1 parent 6bda277 commit 514d318

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

scripts/install.tpl.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,37 @@ function kubectl_wait_rollout() {
4141
kubectl rollout status --namespace="${namespace}" "${runtime}" --timeout="${timeout}"
4242
}
4343

44+
function kubectl_wait_for_caBundle() {
45+
resource=$1
46+
jsonpath_query=$2
47+
timeout=$3
48+
49+
start_time=$(date +%s)
50+
while true; do
51+
caBundle_value=$(kubectl get "${resource}" -o jsonpath="${jsonpath_query}" 2>/dev/null || echo "")
52+
53+
if [[ -n "${caBundle_value}" ]]; then
54+
echo "${resource} has populated ${jsonpath_query}."
55+
break
56+
fi
57+
58+
if [[ $(( $(date +%s) - start_time )) -ge ${timeout} ]]; then
59+
echo "Timed out waiting for ${resource} to populate ${jsonpath_query}."
60+
exit 1
61+
fi
62+
63+
sleep 5
64+
done
65+
}
66+
67+
4468
kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/${cert_mgr_version}/cert-manager.yaml"
4569
# Wait for cert-manager to be fully ready
4670
kubectl_wait "cert-manager" "deployment/cert-manager-webhook" "60s"
4771
kubectl_wait "cert-manager" "deployment/cert-manager-cainjector" "60s"
4872
kubectl_wait "cert-manager" "deployment/cert-manager" "60s"
49-
kubectl wait mutatingwebhookconfigurations/cert-manager-webhook --for=jsonpath='{.webhooks[0].clientConfig.caBundle}' --timeout=60s
50-
kubectl wait validatingwebhookconfigurations/cert-manager-webhook --for=jsonpath='{.webhooks[0].clientConfig.caBundle}' --timeout=60s
73+
kubectl_wait_for_caBundle "mutatingwebhookconfigurations/cert-manager-webhook" '{.webhooks[0].clientConfig.caBundle}' 60
74+
kubectl_wait_for_caBundle "validatingwebhookconfigurations/cert-manager-webhook" '{.webhooks[0].clientConfig.caBundle}' 60
5175

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

0 commit comments

Comments
 (0)