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..bef6bf099a 100644 --- a/Makefile +++ b/Makefile @@ -444,10 +444,13 @@ 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-cluster: $(KIND) #EXHELP Standup a kind cluster. + $(eval KIND_NODE_IMAGE := $(shell K8S_VERSION=v$(K8S_VERSION) $(VALIDATE_KINDEST_NODE_SCRIPT))) -$(KIND) delete cluster --name $(KIND_CLUSTER_NAME) - $(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG) + $(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 @@ -456,8 +459,32 @@ 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=v$(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. + @KIND_VER=$$($(KIND) version | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+'); \ + 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..."; \ + IMAGES=$$(curl -sfL "https://api.github.com/repos/kubernetes-sigs/kind/releases/tags/$$KIND_VER" \ + | grep -oE 'kindest/node:v[0-9]+\.[0-9]+\.[0-9]+' | sort -u); \ + if [ -z "$$IMAGES" ]; then echo "Error: no kindest/node images found for kind $$KIND_VER." >&2; exit 1; fi; \ + CONTENT=$$(<$(VALIDATE_KINDEST_NODE_SCRIPT)); \ + echo "$$CONTENT" | 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_KINDEST_NODE_SCRIPT) #SECTION Build 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}"