Skip to content

Commit 7caa00f

Browse files
Upgrade from Kubebuilder 4.5.2 to 4.6.0 and add support for k8s 1.33
Signed-off-by: Camila Macedo <[email protected]>
1 parent 1bf4815 commit 7caa00f

File tree

44 files changed

+528
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+528
-388
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export IMAGE_VERSION = v1.40.0
99
export SIMPLE_VERSION = $(shell (test "$(shell git describe --tags)" = "$(shell git describe --tags --abbrev=0)" && echo $(shell git describe --tags)) || echo $(shell git describe --tags --abbrev=0)+git)
1010
export GIT_VERSION = $(shell git describe --dirty --tags --always)
1111
export GIT_COMMIT = $(shell git rev-parse HEAD)
12-
export K8S_VERSION = 1.32.0
12+
export K8S_VERSION = 1.33.0
1313

1414
# Build settings
1515
export TOOLS_DIR = tools/bin
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
entries:
2+
- description: >
3+
For Go-based operators, upgrade the Go version from `1.23` to `1.24`
4+
kind: "change"
5+
breaking: true
6+
migration:
7+
header: Upgrade Go version to 1.24
8+
body: |
9+
Update the Go version used to `1.24`. This affects:
10+
11+
**Dockerfile:**
12+
```dockerfile
13+
-FROM golang:1.23 AS builder
14+
+FROM golang:1.24 AS builder
15+
```
16+
17+
**.devcontainer/devcontainer.json:**
18+
```json
19+
- "image": "golang:1.23",
20+
+ "image": "golang:1.24",
21+
```
22+
23+
**go.mod:**
24+
```go
25+
-go 1.23.0
26+
+go 1.24.0
27+
```
28+
29+
- description: >
30+
For Go-based operators, upgrade golangci-lint to `v2.1.0` and update `.golangci.yml`
31+
to the v2 config format with enhanced structure and controls.
32+
kind: "change"
33+
breaking: false
34+
migration:
35+
header: Upgrade golangci-lint and use v2 config
36+
body: |
37+
Update golangci-lint usage across the project:
38+
39+
**Makefile:**
40+
```makefile
41+
-GOLANGCI_LINT_VERSION ?= v1.63.4
42+
+GOLANGCI_LINT_VERSION ?= v2.1.0
43+
44+
-$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
45+
+$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
46+
```
47+
48+
**GitHub Actions Workflow:**
49+
```yaml
50+
- uses: golangci/golangci-lint-action@v6
51+
+ uses: golangci/golangci-lint-action@v8
52+
```
53+
54+
**.golangci.yml:**
55+
Convert to v2 layout with keys like `version`, `linters`, `settings`, `formatters`, `exclusions`.
56+
You might want to copy and paste the file from the Memcached sample from the tag release `v1.40.0`: [testdata/go/v4/memcached-operator/.golangci.yml](https://github.com/operator-framework/operator-sdk/tree/v1.40.0/testdata/go/v4/memcached-operator/.golangci.yml)
57+
58+
- description: >
59+
For Go-based operators, upgrade controller-gen from `v0.17.2` to `v0.18.0`.
60+
kind: "change"
61+
breaking: false
62+
migration:
63+
header: Upgrade controller-gen to `v0.18.0`
64+
body: |
65+
Update controller-gen tooling and annotations:
66+
67+
**Makefile:**
68+
```makefile
69+
-CONTROLLER_TOOLS_VERSION ?= v0.17.2
70+
+CONTROLLER_TOOLS_VERSION ?= v0.18.0
71+
```
72+
73+
Run `make generate` to regenerate code and manifests with the new version.
74+
75+
- description: >
76+
For Go-based operators, upgrade controller-runtime from `v0.20.4` to `v0.21.0`
77+
and kubernetes dependencies to `v0.33`.
78+
kind: "change"
79+
breaking: false
80+
migration:
81+
header: Upgrade controller-runtime to `v0.21.0`
82+
body: |
83+
Update the `go.mod` import:
84+
```go
85+
-sigs.k8s.io/controller-runtime v0.20.4
86+
+sigs.k8s.io/controller-runtime v0.21.0
87+
```
88+
89+
Run `go mod tidy` to upgrade the k8s dependencies.
90+
91+
- description: >
92+
For Go-based operators, add new target to setup/teardown Kind cluster for E2E tests
93+
and remove Kind setup from CI workflows.
94+
kind: "addition"
95+
breaking: false
96+
migration:
97+
header: Add cluster setup for e2e tests in Makefile and update CI workflow
98+
body: |
99+
Remove direct Kind commands in GitHub workflows:
100+
101+
**Removed:**
102+
```yaml
103+
- name: Create kind cluster
104+
run: kind create cluster
105+
```
106+
107+
**Added to Makefile:**
108+
```makefile
109+
KIND_CLUSTER ?= memcached-operator-test-e2e
110+
111+
.PHONY: setup-test-e2e
112+
setup-test-e2e:
113+
$(KIND) create cluster --name $(KIND_CLUSTER)
114+
115+
.PHONY: cleanup-test-e2e
116+
cleanup-test-e2e:
117+
$(KIND) delete cluster --name $(KIND_CLUSTER)
118+
```
119+
120+
Update `test-e2e` target to call these appropriately.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/operator-framework/operator-sdk
22

3-
go 1.23.6
3+
go 1.24.3
44

55
require (
66
github.com/blang/semver/v4 v4.0.0
@@ -41,7 +41,7 @@ require (
4141
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e
4242
sigs.k8s.io/controller-runtime v0.20.4
4343
sigs.k8s.io/controller-tools v0.17.2
44-
sigs.k8s.io/kubebuilder/v4 v4.5.2
44+
sigs.k8s.io/kubebuilder/v4 v4.6.0
4545
sigs.k8s.io/yaml v1.4.0
4646
)
4747

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,8 @@ sigs.k8s.io/controller-tools v0.17.2 h1:jNFOKps8WnaRKZU2R+4vRCHnXyJanVmXBWqkuUPF
874874
sigs.k8s.io/controller-tools v0.17.2/go.mod h1:4q5tZG2JniS5M5bkiXY2/potOiXyhoZVw/U48vLkXk0=
875875
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=
876876
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
877-
sigs.k8s.io/kubebuilder/v4 v4.5.2 h1:57lmVU1zwjOZAF28hBhZyaxE6qXreHYekI4yt/Q5rEU=
878-
sigs.k8s.io/kubebuilder/v4 v4.5.2/go.mod h1:oJrPYf8hkfLCh2vb40vD/Gm22CJsFHlGQz1mw2ZiQaY=
877+
sigs.k8s.io/kubebuilder/v4 v4.6.0 h1:SBc37jghs3L2UaEL91A1t5K5dANrEviUDuNic9hMQSw=
878+
sigs.k8s.io/kubebuilder/v4 v4.6.0/go.mod h1:zlXrnLiJPDPpK4hKCUrlgzzLOusfA8Sd8tpYGIrvD00=
879879
sigs.k8s.io/kustomize/api v0.18.0 h1:hTzp67k+3NEVInwz5BHyzc9rGxIauoXferXyjv5lWPo=
880880
sigs.k8s.io/kustomize/api v0.18.0/go.mod h1:f8isXnX+8b+SGLHQ6yO4JG1rdkZlvhaCf/uZbLVMb0U=
881881
sigs.k8s.io/kustomize/kyaml v0.18.1 h1:WvBo56Wzw3fjS+7vBjN6TeivvpbW9GmRaWZ9CIVmt4E=

images/custom-scorecard-tests/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the custom-scorecard-tests binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44

55
WORKDIR /workspace

images/helm-operator/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44

55
WORKDIR /workspace

images/operator-sdk/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the operator-sdk binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44

55
WORKDIR /workspace

images/scorecard-test-kuttl/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the scorecard-test-kuttl binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44
ARG BUILDPLATFORM
55

images/scorecard-test/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the scorecard-test binary
2-
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
33
ARG TARGETARCH
44

55
WORKDIR /workspace

internal/plugins/manifests/v2/init.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import (
2121
"path/filepath"
2222
"strings"
2323

24-
"sigs.k8s.io/kubebuilder/v4/pkg/plugin/util"
25-
2624
"github.com/spf13/afero"
2725
"sigs.k8s.io/kubebuilder/v4/pkg/config"
2826
"sigs.k8s.io/kubebuilder/v4/pkg/machinery"
@@ -127,15 +125,6 @@ func (s *initSubcommand) Scaffold(fs machinery.Filesystem) error {
127125
return err
128126
}
129127

130-
// TODO: remove this when we bump kubebuilder to v5.x
131-
// Not adopt changes introduced by mistake in the default Makefile of kubebuilder v4.x.
132-
if operatorType == projutil.OperatorTypeGo {
133-
err = util.ReplaceInFile("Makefile", makefileTestE2ETarget, "")
134-
if err != nil {
135-
return fmt.Errorf("error replacing Makefile: %w", err)
136-
}
137-
}
138-
139128
return nil
140129
}
141130

@@ -322,17 +311,4 @@ catalog-build: opm ## Build a catalog image.
322311
catalog-push: ## Push a catalog image.
323312
$(MAKE) docker-push IMG=$(CATALOG_IMG)
324313
`
325-
326-
// TODO: remove it when we bump kubebuilder to v5.x
327-
// We will not adopt this change since it did not work and was a bug introduced in the
328-
// default Makefile of kubebuilder v4.x.
329-
makefileTestE2ETarget = `@command -v $(KIND) >/dev/null 2>&1 || { \
330-
echo "Kind is not installed. Please install Kind manually."; \
331-
exit 1; \
332-
}
333-
@$(KIND) get clusters | grep -q 'kind' || { \
334-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
335-
exit 1; \
336-
}
337-
`
338314
)

0 commit comments

Comments
 (0)