diff --git a/Makefile b/Makefile index 7ef00ffafc..d10ff7ab85 100644 --- a/Makefile +++ b/Makefile @@ -104,9 +104,6 @@ endif ENVTEST_KUBE_VERSION ?= $(KUBE_MINOR).x KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use -p path $(KUBE_MINOR).x) -# Kind node image tags are in the format x.y.z we pin to version x.y.0 because patch releases and node images -# are not guaranteed to be available when a new version of the kube apis is released -KIND_CLUSTER_IMAGE := kindest/node:v$(KUBE_MINOR).0 KIND_CLUSTER_NAME ?= kind-olmv0 # Targets # @@ -224,7 +221,8 @@ kind-clean: $(KIND) #HELP Delete kind cluster $KIND_CLUSTER_NAME (default: kind- .PHONY: kind-create kind-create: kind-clean #HELP Create a new kind cluster $KIND_CLUSTER_NAME (default: kind-olmv0) - $(KIND) create cluster --name $(KIND_CLUSTER_NAME) --image $(KIND_CLUSTER_IMAGE) $(KIND_CREATE_OPTS) + env K8S_VERSION=v$(KUBE_MINOR) KIND=$(KIND) GOBIN=$(GOBIN) hack/tools/validate_kindest_node.sh + $(KIND) create cluster --name $(KIND_CLUSTER_NAME) $(KIND_CREATE_OPTS) $(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME) .PHONY: deploy diff --git a/hack/tools/validate_kindest_node.sh b/hack/tools/validate_kindest_node.sh new file mode 100755 index 0000000000..c1fdcc3137 --- /dev/null +++ b/hack/tools/validate_kindest_node.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# This script verifies that the version of kind used for testing uses a major.minor version of k8s that operator-controller does + +# 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]+') + +# Compare the versions +if [ "${KIND_VER}" != "${K8S_VERSION}" ]; then + echo "kindest/node:${KIND_VER} version does not match k8s ${K8S_VERSION}" + exit 1 +fi +exit 0