From fa8b1d9d44d4beb338819aa826492cf6a807b730 Mon Sep 17 00:00:00 2001 From: Predrag Knezevic Date: Fri, 5 Jun 2026 14:08:26 +0200 Subject: [PATCH] :seedling: Bump kind to v0.32.0 and rework kindest/node image selection Bump kind from v0.31.0 to v0.32.0. Rework validate_kindest_node.sh to embed all released kindest/node images for the pinned kind version (as a case statement), rather than checking strict equality against kind's default image. This allows kind to be bumped independently of k8s dependency upgrades, since kind v0.32.0 supports k8s 1.33 through 1.36. The script now outputs the correct kindest/node image for the project's K8S_VERSION, and kind-cluster passes it via --image. A new make target `kind-update-images` regenerates the image map by querying the kind GitHub release. The tilt CI workflow is updated to symlink the bingo-managed kind binary as `kind` on the PATH, so tilt's `kind load` calls use the correct version. Co-authored-by: Predrag Knezevic --- .bingo/Variables.mk | 6 ++-- .bingo/kind.mod | 2 +- .bingo/kind.sum | 2 ++ .bingo/variables.env | 2 +- .github/workflows/tilt.yaml | 2 ++ Makefile | 19 ++++++++---- hack/tools/update-kind-images.sh | 47 +++++++++++++++++++++++++++++ hack/tools/validate_kindest_node.sh | 44 +++++++++++++-------------- 8 files changed, 90 insertions(+), 34 deletions(-) create mode 100755 hack/tools/update-kind-images.sh diff --git a/.bingo/Variables.mk b/.bingo/Variables.mk index 28ccf20c61..606269b18e 100644 --- a/.bingo/Variables.mk +++ b/.bingo/Variables.mk @@ -65,11 +65,11 @@ $(HELM): $(BINGO_DIR)/helm.mod @echo "(re)installing $(GOBIN)/helm-v3.18.4" @cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=helm.mod -o=$(GOBIN)/helm-v3.18.4 "helm.sh/helm/v3/cmd/helm" -KIND := $(GOBIN)/kind-v0.31.0 +KIND := $(GOBIN)/kind-v0.32.0 $(KIND): $(BINGO_DIR)/kind.mod @# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. - @echo "(re)installing $(GOBIN)/kind-v0.31.0" - @cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kind.mod -o=$(GOBIN)/kind-v0.31.0 "sigs.k8s.io/kind" + @echo "(re)installing $(GOBIN)/kind-v0.32.0" + @cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kind.mod -o=$(GOBIN)/kind-v0.32.0 "sigs.k8s.io/kind" KUBE_SCORE := $(GOBIN)/kube-score-v1.20.0 $(KUBE_SCORE): $(BINGO_DIR)/kube-score.mod diff --git a/.bingo/kind.mod b/.bingo/kind.mod index 589ee9e908..3389acb2b4 100644 --- a/.bingo/kind.mod +++ b/.bingo/kind.mod @@ -2,4 +2,4 @@ module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT go 1.24.6 -require sigs.k8s.io/kind v0.31.0 +require sigs.k8s.io/kind v0.32.0 diff --git a/.bingo/kind.sum b/.bingo/kind.sum index fadffa939b..49cecf9d11 100644 --- a/.bingo/kind.sum +++ b/.bingo/kind.sum @@ -31,5 +31,7 @@ sigs.k8s.io/kind v0.30.0 h1:2Xi1KFEfSMm0XDcvKnUt15ZfgRPCT0OnCBbpgh8DztY= sigs.k8s.io/kind v0.30.0/go.mod h1:FSqriGaoTPruiXWfRnUXNykF8r2t+fHtK0P0m1AbGF8= sigs.k8s.io/kind v0.31.0 h1:UcT4nzm+YM7YEbqiAKECk+b6dsvc/HRZZu9U0FolL1g= sigs.k8s.io/kind v0.31.0/go.mod h1:FSqriGaoTPruiXWfRnUXNykF8r2t+fHtK0P0m1AbGF8= +sigs.k8s.io/kind v0.32.0 h1:p9hscbj98u/qyrjVpjId86LI70nQmbSsipV7wCG10Xk= +sigs.k8s.io/kind v0.32.0/go.mod h1:FSqriGaoTPruiXWfRnUXNykF8r2t+fHtK0P0m1AbGF8= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/.bingo/variables.env b/.bingo/variables.env index 58417ccf8d..0c0cdd1b17 100644 --- a/.bingo/variables.env +++ b/.bingo/variables.env @@ -24,7 +24,7 @@ GORELEASER="${GOBIN}/goreleaser-v2.11.2" HELM="${GOBIN}/helm-v3.18.4" -KIND="${GOBIN}/kind-v0.31.0" +KIND="${GOBIN}/kind-v0.32.0" KUBE_SCORE="${GOBIN}/kube-score-v1.20.0" diff --git a/.github/workflows/tilt.yaml b/.github/workflows/tilt.yaml index 71c05d3115..cbc76af407 100644 --- a/.github/workflows/tilt.yaml +++ b/.github/workflows/tilt.yaml @@ -33,6 +33,8 @@ jobs: run: | cd operator-controller make kind-cluster + # Symlink bingo-managed kind binary so tilt can find it as 'kind' + ln -sf "$(make --no-print-directory --eval='print-kind: ; @echo $(KIND)' print-kind)" /usr/local/bin/kind - name: Test Tilt run: | cd operator-controller diff --git a/Makefile b/Makefile index 0b85267564..1a96685e7d 100644 --- a/Makefile +++ b/Makefile @@ -444,11 +444,14 @@ kind-deploy-experimental: manifests cp $(CATALOGS_MANIFEST) $(DEFAULT_CATALOG) envsubst '$$DEFAULT_CATALOG,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' < scripts/install.tpl.sh | bash -s +VALIDATE_KINDEST_NODE_SCRIPT := hack/tools/validate_kindest_node.sh + .PHONY: kind-cluster -kind-cluster: $(KIND) kind-verify-versions #EXHELP Standup a kind cluster. - -$(KIND) delete cluster --name $(KIND_CLUSTER_NAME) - $(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG) - $(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME) +kind-cluster: $(KIND) #EXHELP Standup a kind cluster. + @KIND_NODE_IMAGE=$$(K8S_VERSION=$(K8S_VERSION) $(VALIDATE_KINDEST_NODE_SCRIPT)) || exit 1; \ + $(KIND) delete cluster --name $(KIND_CLUSTER_NAME) 2>/dev/null || true; \ + $(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG) --image "$$KIND_NODE_IMAGE"; \ + $(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME); \ kubectl wait --for=condition=Ready nodes --all --timeout=2m .PHONY: kind-clean @@ -456,8 +459,12 @@ kind-clean: $(KIND) #EXHELP Delete the kind cluster. $(KIND) delete cluster --name $(KIND_CLUSTER_NAME) .PHONY: kind-verify-versions -kind-verify-versions: $(KIND) - env K8S_VERSION=v$(K8S_VERSION) KIND=$(KIND) GOBIN=$(GOBIN) hack/tools/validate_kindest_node.sh +kind-verify-versions: + @K8S_VERSION=$(K8S_VERSION) $(VALIDATE_KINDEST_NODE_SCRIPT) > /dev/null + +.PHONY: kind-update-images +kind-update-images: $(KIND) #EXHELP Regenerate the kindest/node image map in validate_kindest_node.sh. + hack/tools/update-kind-images.sh $(KIND) #SECTION Build diff --git a/hack/tools/update-kind-images.sh b/hack/tools/update-kind-images.sh new file mode 100755 index 0000000000..f3a5a9ac4f --- /dev/null +++ b/hack/tools/update-kind-images.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -euo pipefail +# Regenerates the KIND_IMAGES block in validate_kindest_node.sh +# by fetching released kindest/node images from the kind GitHub release. +# +# Usage: update-kind-images.sh + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +VALIDATE_SCRIPT="${SCRIPT_DIR}/validate_kindest_node.sh" + +KIND="${1:?Usage: $0 }" + +KIND_VER=$(${KIND} version | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' || true) +if [ -z "${KIND_VER}" ]; then + echo "Error: could not determine kind version." >&2 + exit 1 +fi + +echo "Fetching kindest/node images for kind ${KIND_VER}..." +RELEASE_BODY=$(curl -sfL "https://api.github.com/repos/kubernetes-sigs/kind/releases/tags/${KIND_VER}") +IMAGES=$(echo "${RELEASE_BODY}" | grep -oE 'kindest/node:v[0-9]+\.[0-9]+\.[0-9]+' | sort -u || true) +if [ -z "${IMAGES}" ]; then + echo "Error: no kindest/node images found for kind ${KIND_VER}." >&2 + exit 1 +fi + +TMP=$(mktemp) +trap 'rm -f "${TMP}"' EXIT + +awk -v ver="${KIND_VER}" -v images="${IMAGES}" \ + 'BEGIN{in_block=0} + /^# --- BEGIN KIND IMAGES ---/{print; in_block=1; + print "# kind " ver + print "case \"${K8S_MINOR}\" in" + n=split(images,a,"\n") + for(i=1;i<=n;i++){if(a[i]=="")continue + minor=a[i]; sub(/.*:v/,"",minor); sub(/\.[0-9]+$/,"",minor) + print " " minor ") IMAGE=\"" a[i] "\" ;;"} + print " *) IMAGE=\"\" ;;" + print "esac"; next} + /^# --- END KIND IMAGES ---/{in_block=0; print; next} + in_block{next} + {print}' "${VALIDATE_SCRIPT}" > "${TMP}" + +mv "${TMP}" "${VALIDATE_SCRIPT}" +chmod +x "${VALIDATE_SCRIPT}" +echo "Updated ${VALIDATE_SCRIPT} with images for kind ${KIND_VER}" diff --git a/hack/tools/validate_kindest_node.sh b/hack/tools/validate_kindest_node.sh index f00632bcca..1194f91662 100755 --- a/hack/tools/validate_kindest_node.sh +++ b/hack/tools/validate_kindest_node.sh @@ -1,31 +1,29 @@ #!/bin/bash -# This script verifies that the version of kind used for testing uses a major.minor version of k8s that operator-controller does +set -euo pipefail +# Outputs the kindest/node image for the given K8S_VERSION. +# The KIND_IMAGES block below is regenerated by `make kind-update-images`. -# Extract the version of kind, by removing the "${GOBIN}/kind-" prefix -KIND=${KIND#${GOBIN}/kind-} - -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) +if [ -z "${K8S_VERSION:-}" ]; then + echo "Error: K8S_VERSION is not set." >&2 + exit 1 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 +K8S_MINOR=$(echo "${K8S_VERSION}" | sed -E 's/^v?([0-9]+\.[0-9]+).*/\1/') -if [ -z "${KIND_VER}" ]; then - echo "Unable to determine kindest/node version" - exit 1 -fi +# --- BEGIN KIND IMAGES --- +# kind v0.32.0 +case "${K8S_MINOR}" in + 1.33) IMAGE="kindest/node:v1.33.12" ;; + 1.34) IMAGE="kindest/node:v1.34.8" ;; + 1.35) IMAGE="kindest/node:v1.35.5" ;; + 1.36) IMAGE="kindest/node:v1.36.1" ;; + *) IMAGE="" ;; +esac +# --- END KIND IMAGES --- -# Compare the versions -if [ "${KIND_VER}" != "${K8S_VERSION}" ]; then - echo "kindest/node:${KIND_VER} version does not match k8s ${K8S_VERSION}" +if [ -z "${IMAGE}" ]; then + echo "Error: no kindest/node image for k8s ${K8S_MINOR}." >&2 + echo "Run 'make kind-update-images' after bumping kind." >&2 exit 1 fi -exit 0 +echo "${IMAGE}"