Skip to content

Commit

Permalink
Merge pull request #4482 from jackfrancis/cherry-pick-4470-to-release…
Browse files Browse the repository at this point in the history
…-1.12

[release-1.12] overcome transient failures + retry when creating test cluster
  • Loading branch information
k8s-ci-robot authored Jan 19, 2024
2 parents ab09e78 + 4acd138 commit d8c7272
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,14 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KUBECTL) $(KIND) ## Create
./hack/create-custom-cloud-provider-config.sh

# Deploy CAPI
curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.5/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -
timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.5/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done"

# Deploy CAAPH
curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm/releases/download/v0.1.0-alpha.10/addon-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -
timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm/releases/download/v0.1.0-alpha.10/addon-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done"

# Deploy CAPZ
$(KIND) load docker-image $(CONTROLLER_IMG)-$(ARCH):$(TAG) --name=$(KIND_CLUSTER_NAME)
$(KUSTOMIZE) build config/default | $(ENVSUBST) | $(KUBECTL) apply -f - --server-side=true
timeout --foreground 300 bash -c "until $(KUSTOMIZE) build config/default | $(ENVSUBST) | $(KUBECTL) apply -f - --server-side=true; do sleep 5; done"

# Wait for CAPI deployments
$(KUBECTL) wait --for=condition=Available --timeout=5m -n capi-system deployment -l cluster.x-k8s.io/provider=cluster-api
Expand All @@ -322,8 +322,8 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KUBECTL) $(KIND) ## Create
timeout --foreground 300 bash -c "until $(KUBECTL) get clusterresourcesets -A; do sleep 3; done"

# install Windows Calico cluster resource set
$(KUBECTL) create configmap calico-windows-addon --from-file="$(ADDONS_DIR)/windows/calico" --dry-run=client -o yaml | kubectl apply -f -
$(KUBECTL) apply -f templates/addons/windows/calico-resource-set.yaml
timeout --foreground 300 bash -c "until $(KUBECTL) create configmap calico-windows-addon --from-file=$(ADDONS_DIR)/windows/calico --dry-run=client -o yaml | kubectl apply -f -; do sleep 5; done"
timeout --foreground 300 bash -c "until $(KUBECTL) apply -f templates/addons/windows/calico-resource-set.yaml; do sleep 5; done"

# Wait for CAPZ deployments
$(KUBECTL) wait --for=condition=Available --timeout=5m -n capz-system deployment --all
Expand All @@ -339,11 +339,11 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KUBECTL) $(KIND) ## Create
create-workload-cluster: $(ENVSUBST) $(KUBECTL) ## Create a workload cluster.
# Create workload Cluster.
@if [ -f "$(TEMPLATES_DIR)/$(CLUSTER_TEMPLATE)" ]; then \
$(ENVSUBST) < "$(TEMPLATES_DIR)/$(CLUSTER_TEMPLATE)" | $(KUBECTL) apply -f -; \
timeout --foreground 300 bash -c "until $(ENVSUBST) < $(TEMPLATES_DIR)/$(CLUSTER_TEMPLATE) | $(KUBECTL) apply -f -; do sleep 5; done"; \
elif [ -f "$(CLUSTER_TEMPLATE)" ]; then \
$(ENVSUBST) < "$(CLUSTER_TEMPLATE)" | $(KUBECTL) apply -f -; \
timeout --foreground 300 bash -c "until $(ENVSUBST) < $(CLUSTER_TEMPLATE) | $(KUBECTL) apply -f -; do sleep 5; done"; \
else \
curl --retry "$(CURL_RETRIES)" "$(CLUSTER_TEMPLATE)" | "$(ENVSUBST)" | $(KUBECTL) apply -f -; \
timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) $(CLUSTER_TEMPLATE) | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done"; \
fi

# Wait for the kubeconfig to become available.
Expand Down
36 changes: 25 additions & 11 deletions hack/create-dev-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ make envsubst

export REGISTRY="${REGISTRY:-registry.local/fake}"

export CLUSTER_CREATE_ATTEMPTS="${CLUSTER_CREATE_ATTEMPTS:-3}"

# Cluster settings.
export CLUSTER_NAME="${CLUSTER_NAME:-capz-test}"
export AZURE_VNET_NAME=${CLUSTER_NAME}-vnet
Expand Down Expand Up @@ -62,14 +64,26 @@ capz::util::generate_ssh_key
echo "================ DOCKER BUILD ==============="
PULL_POLICY=IfNotPresent make modules docker-build

echo "================ MAKE CLEAN ==============="
make clean

echo "================ KIND RESET ==============="
make kind-reset

echo "================ INSTALL TOOLS ==============="
make install-tools

echo "================ CREATE CLUSTER ==============="
make create-cluster
setup() {
echo "================ MAKE CLEAN ==============="
make clean

echo "================ KIND RESET ==============="
make kind-reset

echo "================ INSTALL TOOLS ==============="
make install-tools
}

create_cluster() {
echo "================ CREATE CLUSTER ==============="
make create-cluster
}

retries=$CLUSTER_CREATE_ATTEMPTS
while ((retries > 0)); do
create_cluster && break
setup
sleep 5
((retries --))
done

0 comments on commit d8c7272

Please sign in to comment.