Skip to content

Commit efd97f8

Browse files
fix: resolve jsonpath error when waiting for caBundle in webhook configurations
- Fixed error: 'deployment.apps/cert-manager-webhook condition met deployment.apps/cert-manager-cainjector condition met deployment.apps/cert-manager condition met error: jsonpath wait format must be --for=jsonpath='{.status.readyReplicas}'=3' - The error appears because 'kubectl wait' isn’t fully compatible with JSONPath on non-status fields, especially for resources like 'mutatingwebhookconfigurations' and 'validatingwebhookconfigurations'. 'kubectl wait' expects status fields related to replicas, which aren’t present in these configurations. - Replaced 'kubectl wait' with the 'kubectl_wait_for_caBundle' function, which uses a loop with 'kubectl get' to repeatedly check the 'caBundle' field until it is populated. This bypasses the limitations of 'kubectl wait' and avoids replica-based conditions for webhook configurations.
1 parent 6bda277 commit efd97f8

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

scripts/install.tpl.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,36 @@ 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+
4467
kubectl apply -f "https://github.com/cert-manager/cert-manager/releases/download/${cert_mgr_version}/cert-manager.yaml"
4568
# Wait for cert-manager to be fully ready
4669
kubectl_wait "cert-manager" "deployment/cert-manager-webhook" "60s"
4770
kubectl_wait "cert-manager" "deployment/cert-manager-cainjector" "60s"
4871
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
72+
kubectl_wait_for_caBundle "mutatingwebhookconfigurations/cert-manager-webhook" '{.webhooks[0].clientConfig.caBundle}' 60
73+
kubectl_wait_for_caBundle "validatingwebhookconfigurations/cert-manager-webhook" '{.webhooks[0].clientConfig.caBundle}' 60
5174

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

0 commit comments

Comments
 (0)