Skip to content

Commit d284f90

Browse files
committed
Bump go1.24, Kubernetes dependencies to v1.33.x and update tooling
- Upgrade k8s.io/* dependencies from v0.30.x to v0.33.x - Update controller-runtime from v0.18.6 to v0.21.0 - Bump Go version from 1.22.12 to 1.24.0 with toolchain 1.24.3 - Update operator-sdk from v1.38.0 to v1.40.0 - Bump controller-gen from v0.14.0 to v0.18.0 - Update kustomize from v5.5.0 to v5.6.0 - Upgrade kind from v0.23.0 to v0.29.0 - Update kubectl to v1.33.1 - Use the new envtest go binary - Make sure cached controller-gen is used Signed-off-by: Konstantinos Karampogias <[email protected]>
1 parent 060015c commit d284f90

File tree

11 files changed

+731
-676
lines changed

11 files changed

+731
-676
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1.2
22

3-
FROM --platform=$BUILDPLATFORM docker.io/golang:1.22.12 AS builder
3+
FROM --platform=$BUILDPLATFORM docker.io/golang:1.24.3 AS builder
44
ARG GIT_COMMIT=dev
55
ARG GIT_BRANCH=dev
66

Makefile

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ else
4646
GOBIN=$(shell go env GOBIN)
4747
endif
4848

49-
OPERATOR_SDK_VERSION ?= v1.38.0
49+
OPERATOR_SDK_VERSION ?= v1.40.0
5050
OLM_VERSION ?= v0.18.3
51-
OPM_VERSION ?= v1.23.2
52-
KUSTOMIZE_VERSION ?= v5.5.0
51+
OPM_VERSION ?= v1.55.2
52+
KUSTOMIZE_VERSION ?= v5.6.0
5353
KUSTOMIZE=$(shell pwd)/_cache/kustomize
54-
KIND ?= $(shell pwd)/_cache/kind
55-
KIND_VERSION=v0.23.0
54+
KIND_VERSION ?= v0.29.0
55+
KUBECTL_VERSION ?= v1.33.1
56+
ENVTEST_VERSION ?= 1.33.0
57+
CONTROLLER_GEN_VERSION ?= v0.18.0
5658
CACHE_PATH=$(shell pwd)/_cache
5759

5860

@@ -62,11 +64,9 @@ OPM_TOOL_URL=https://api.github.com/repos/operator-framework/operator-registry/r
6264
TESTS_REPORTS_PATH ?= /tmp/test_e2e_logs/
6365
VALIDATION_TESTS_REPORTS_PATH ?= /tmp/test_validation_logs/
6466

65-
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
66-
test: generate fmt vet manifests ## Run unit and integration tests
67-
mkdir -p ${ENVTEST_ASSETS_DIR}
68-
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
69-
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test -race ./... -coverprofile cover.out
67+
test: generate fmt vet manifests setup-envtest ## Run unit and integration tests
68+
source <(_cache/setup-envtest use -p env --bin-dir ${CACHE_PATH} ${ENVTEST_VERSION} ) && \
69+
go test -race ./... -coverprofile cover.out
7070

7171
all: manager ## Default make target if no options specified
7272

@@ -126,7 +126,7 @@ bin: manifests kustomize ## Create manifests
126126
$(KUSTOMIZE) build config/metallb_rbac >> bin/$(BIN_FILE)
127127

128128
manifests: controller-gen generate-metallb-manifests ## Generate manifests e.g. CRD, RBAC etc.
129-
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=metallb-manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
129+
$(CACHE_PATH)/controller-gen $(CRD_OPTIONS) rbac:roleName=metallb-manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
130130
sed -i -e 's/validating-webhook-configuration/metallb-operator-webhook-configuration/g' config/webhook/manifests.yaml
131131
sed -i -e 's/webhook-service/metallb-operator-webhook-service/g' config/webhook/manifests.yaml
132132

@@ -138,7 +138,7 @@ vet: ## Run go vet against code
138138
go vet ./...
139139

140140
generate: controller-gen ## Generate code
141-
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
141+
$(CACHE_PATH)/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
142142

143143
# Build the docker image
144144
docker-build: ## Build the docker image
@@ -162,11 +162,11 @@ build-bundle: ## Build the bundle image.
162162

163163
.PHONY: kind-cluster
164164
kind-cluster: kind
165-
KIND_BIN=$(KIND) hack/kind/kind.sh
165+
KIND_BIN=$(CACHE_PATH)/kind hack/kind/kind.sh
166166

167167
.PHONY: load-on-kind
168168
load-on-kind: docker-build kind-cluster ## Load the docker image into the kind cluster.
169-
$(KIND) load docker-image ${IMG}
169+
$(CACHE_PATH)/kind load docker-image ${IMG}
170170

171171
deploy-olm: export KIND_WITH_REGISTRY=true
172172
deploy-olm: operator-sdk kind-cluster ## deploys OLM on the cluster
@@ -194,16 +194,19 @@ build-and-push-bundle-images: docker-build docker-push ## Generate and push bun
194194
deploy-prometheus:
195195
hack/deploy_prometheus.sh
196196

197-
# find or download controller-gen
198-
# download controller-gen if necessary
197+
setup-envtest:
198+
mkdir -p _cache
199+
ifeq (,$(findstring v0.0.0,$(shell _cache/setup-envtest version)))
200+
GOBIN=$(CACHE_PATH) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
201+
endif
202+
199203
controller-gen:
200-
ifeq (, $(shell which controller-gen))
201-
go install sigs.k8s.io/controller-tools/cmd/[email protected]
202-
CONTROLLER_GEN=$(GOBIN)/controller-gen
203-
else
204-
CONTROLLER_GEN=$(shell which controller-gen)
204+
mkdir -p _cache
205+
ifeq (,$(findstring $(CONTROLLER_GEN_VERSION),$(shell _cache/controller-gen --version)))
206+
GOBIN=$(CACHE_PATH) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)
205207
endif
206208

209+
207210
# Get the current operator-sdk binary into the _cache dir.
208211
kustomize:
209212
mkdir -p _cache
@@ -246,7 +249,7 @@ kubectl:
246249
ifeq (, $(shell which kubectl))
247250
@{ \
248251
set -e ;\
249-
curl -LO https://dl.k8s.io/release/v1.23.0/bin/linux/amd64/kubectl > $(GOBIN)/kubectl ;\
252+
curl -LO https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl > $(GOBIN)/kubectl ;\
250253
chmod u+x $(GOBIN)/kubectl ;\
251254
}
252255
endif

api/v1beta1/metallb_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
v1 "k8s.io/api/core/v1"
2626
"k8s.io/apimachinery/pkg/runtime"
2727
ctrl "sigs.k8s.io/controller-runtime"
28-
"sigs.k8s.io/controller-runtime/pkg/webhook"
2928
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3029
)
3130

@@ -40,8 +39,6 @@ func (metallb *MetalLB) SetupWebhookWithManager(mgr ctrl.Manager, externalFRRK8s
4039

4140
//+kubebuilder:webhook:verbs=create;update,path=/validate-metallb-io-v1beta1-metallb,mutating=false,failurePolicy=fail,groups=metallb.io,resources=metallbs,versions=v1beta1,name=metallbvalidationwebhook.metallb.io,sideEffects=None,admissionReviewVersions=v1
4241

43-
var _ webhook.Validator = &MetalLB{}
44-
4542
// ValidateCreate implements webhook.Validator so a webhook will be registered for MetalLB.
4643
func (metallb *MetalLB) ValidateCreate() (admission.Warnings, error) {
4744
if err := metallb.Validate(); err != nil {

0 commit comments

Comments
 (0)