@@ -30,6 +30,27 @@ function header_text {
3030 echo " $header $* $reset "
3131}
3232
33+ function kubectl_apply_with_retry() {
34+ local max_attempts=5
35+ local delay=5
36+ local attempt
37+
38+ for attempt in $( seq 1 $max_attempts ) ; do
39+ if kubectl apply " $@ " ; then
40+ return 0
41+ fi
42+
43+ if [ " $attempt " -lt " $max_attempts " ]; then
44+ header_text " kubectl apply failed (attempt $attempt /$max_attempts ), retrying in ${delay} s..."
45+ sleep " $delay "
46+ delay=$(( delay * 2 ))
47+ fi
48+ done
49+
50+ header_text " kubectl apply failed after $max_attempts attempts"
51+ return 1
52+ }
53+
3354function delete_existing_cluster() {
3455 header_text " Deleting existing Kind cluster..."
3556 kind delete cluster --name " $CLUSTER_NAME " || true
@@ -84,8 +105,6 @@ nodes:
84105 image: kindest/node:$NODE_VERSION
85106- role: worker
86107 image: kindest/node:$NODE_VERSION
87- - role: worker
88- image: kindest/node:$NODE_VERSION
89108containerdConfigPatches:
90109- |-
91110 [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:$REGISTRY_PORT "]
122141
123142function install_tekton() {
124143 header_text " Install Tekton"
125- kubectl apply -f https://infra.tekton.dev/tekton-releases/pipeline/previous/${TEKTON_VERSION} /release.yaml
144+ kubectl_apply_with_retry -f https://infra.tekton.dev/tekton-releases/pipeline/previous/${TEKTON_VERSION} /release.yaml
126145 kubectl patch configmap feature-flags -n tekton-pipelines --type merge -p ' {"data":{"coschedule":"disabled"}}'
127146
128147 header_text " Waiting for Tekton to be ready..."
@@ -132,9 +151,9 @@ function install_tekton() {
132151
133152function install_knative_serving() {
134153 header_text " Installing Knative Serving..."
135- kubectl apply -f https://github.com/knative/serving/releases/download/knative-${SERVING_VERSION} /serving-crds.yaml
136- kubectl apply -f https://github.com/knative/serving/releases/download/knative-${SERVING_VERSION} /serving-core.yaml
137- kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-${SERVING_VERSION} /kourier.yaml
154+ kubectl_apply_with_retry -f https://github.com/knative/serving/releases/download/knative-${SERVING_VERSION} /serving-crds.yaml
155+ kubectl_apply_with_retry -f https://github.com/knative/serving/releases/download/knative-${SERVING_VERSION} /serving-core.yaml
156+ kubectl_apply_with_retry -f https://github.com/knative/net-kourier/releases/download/knative-${SERVING_VERSION} /kourier.yaml
138157
139158 kubectl patch configmap/config-network \
140159 --namespace knative-serving \
@@ -148,14 +167,14 @@ function install_knative_serving() {
148167
149168function install_keda() {
150169 header_text " Installing keda"
151- kubectl apply --server-side -f https://github.com/kedacore/keda/releases/download/${KEDA_VERSION} /keda-${KEDA_VERSION: 1} .yaml
152- kubectl apply --server-side -f https://github.com/kedacore/keda/releases/download/${KEDA_VERSION} /keda-${KEDA_VERSION: 1} -core.yaml
170+ kubectl_apply_with_retry --server-side -f https://github.com/kedacore/keda/releases/download/${KEDA_VERSION} /keda-${KEDA_VERSION: 1} .yaml
171+ kubectl_apply_with_retry --server-side -f https://github.com/kedacore/keda/releases/download/${KEDA_VERSION} /keda-${KEDA_VERSION: 1} -core.yaml
153172 header_text " Waiting for Keda to become ready"
154173 kubectl wait deployment --all --timeout=-1s --for=condition=Available --namespace keda
155174
156175 header_text " Installing keda HTTP add-on"
157- kubectl apply --server-side -f https://github.com/kedacore/http-add-on/releases/download/${KEDA_HTTP_ADDON_VERSION} /keda-add-ons-http-${KEDA_HTTP_ADDON_VERSION: 1} -crds.yaml
158- kubectl apply --server-side -f https://github.com/kedacore/http-add-on/releases/download/${KEDA_HTTP_ADDON_VERSION} /keda-add-ons-http-${KEDA_HTTP_ADDON_VERSION: 1} .yaml
176+ kubectl_apply_with_retry --server-side -f https://github.com/kedacore/http-add-on/releases/download/${KEDA_HTTP_ADDON_VERSION} /keda-add-ons-http-${KEDA_HTTP_ADDON_VERSION: 1} -crds.yaml
177+ kubectl_apply_with_retry --server-side -f https://github.com/kedacore/http-add-on/releases/download/${KEDA_HTTP_ADDON_VERSION} /keda-add-ons-http-${KEDA_HTTP_ADDON_VERSION: 1} .yaml
159178 header_text " Waiting for Keda HTTP add-on to become ready"
160179 kubectl wait deployment --all --timeout=-1s --for=condition=Available --namespace keda
161180}
0 commit comments