From 6682925212ad83a0695c2a22795312f8ff4dcf69 Mon Sep 17 00:00:00 2001 From: Todd Short Date: Tue, 18 Nov 2025 16:05:37 -0500 Subject: [PATCH] Use local cache to check kind version Use the local cached source of kind to determine the k8s version it supports. It avoids hitting github if possible. Signed-off-by: Todd Short --- Makefile | 2 +- hack/tools/validate_kindest_node.sh | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3f7c9af335..c91f952b75 100644 --- a/Makefile +++ b/Makefile @@ -386,7 +386,7 @@ kind-clean: $(KIND) #EXHELP Delete the kind cluster. $(KIND) delete cluster --name $(KIND_CLUSTER_NAME) .PHONY: kind-verify-versions -kind-verify-versions: +kind-verify-versions: $(KIND) env K8S_VERSION=v$(K8S_VERSION) KIND=$(KIND) GOBIN=$(GOBIN) hack/tools/validate_kindest_node.sh diff --git a/hack/tools/validate_kindest_node.sh b/hack/tools/validate_kindest_node.sh index c1fdcc3137..f00632bcca 100755 --- a/hack/tools/validate_kindest_node.sh +++ b/hack/tools/validate_kindest_node.sh @@ -4,8 +4,24 @@ # Extract the version of kind, by removing the "${GOBIN}/kind-" prefix KIND=${KIND#${GOBIN}/kind-} -# Get the version of the image -KIND_VER=$(curl -L -s https://github.com/kubernetes-sigs/kind/raw/refs/tags/${KIND}/pkg/apis/config/defaults/image.go | grep -Eo 'v[0-9]+\.[0-9]+') +GOMODCACHE=$(go env GOMODCACHE) + +REGEX='v[0-9]+\.[0-9]+' + +# Get the version of the image from the local kind build +if [ -d "${GOMODCACHE}" ]; then + KIND_VER=$(grep -Eo "${REGEX}" ${GOMODCACHE}/sigs.k8s.io/kind@${KIND}/pkg/apis/config/defaults/image.go) +fi + +# Get the version of the image from github +if [ -z "${KIND_VER}" ]; then + KIND_VER=$(curl -L -s https://github.com/kubernetes-sigs/kind/raw/refs/tags/${KIND}/pkg/apis/config/defaults/image.go | grep -Eo "${REGEX}") +fi + +if [ -z "${KIND_VER}" ]; then + echo "Unable to determine kindest/node version" + exit 1 +fi # Compare the versions if [ "${KIND_VER}" != "${K8S_VERSION}" ]; then