Skip to content

Commit 263426e

Browse files
committed
Upgrade to Operator SDK 1.41.1
This commit upgrades the ovn-operator to use Operator SDK version 1.41.1, with the following major changes: Project Structure: - Move pkg/ packages to internal/ following Go best practices - Move controllers/ to internal/controller/ per new operator-sdk layout - Replace main.go with cmd/main.go - Add controller and webhook test suites Configuration Updates: - Split certificate management into separate metrics and webhook certs - Add network policies for metrics and webhook traffic - Rename auth_proxy resources to metrics for clarity - Add admin RBAC roles for all CRD types - Update manager deployment configuration and patches - Modernize kustomization configurations Webhook Changes: - Add dedicated webhook implementation in internal/webhook/v1beta1/ - Remove old CRD webhook and CA injection patches - Update webhook manifests and service configuration Cleanup: - Remove obsolete config patches and overlays Dependencies: - Update go.mod and go.sum for operator-sdk 1.41.1 dependencies Jira: OSPRH-22013 Assisted-by: claude-4-sonnet Signed-off-by: Martin Schuppert <[email protected]>
1 parent cc9071d commit 263426e

File tree

159 files changed

+1322
-832
lines changed

Some content is hidden

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

159 files changed

+1322
-832
lines changed

.ci-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: tools
33
namespace: openstack-k8s-operators
4-
tag: ci-build-root-golang-1.24-sdk-1.31
4+
tag: ci-build-root-golang-1.24-sdk-1.41.1

.github/workflows/build-swift-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
operator_name: swift
1818
go_version: 1.24.x
19-
operator_sdk_version: 1.31.0
19+
operator_sdk_version: 1.41.1
2020
secrets:
2121
IMAGENAMESPACE: ${{ secrets.IMAGENAMESPACE }}
2222
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}

.github/workflows/force-bump-pr-manual.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ jobs:
99
with:
1010
operator_name: swift
1111
branch_name: ${{ github.ref_name }}
12-
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.31
12+
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.41.1
1313
secrets:
1414
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}

.github/workflows/force-bump-pr-scheduled.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/force-bump-branches.yaml@main
1111
with:
1212
operator_name: swift
13-
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.31
13+
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.41.1
1414
secrets:
1515
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUN mkdir -p ${DEST_ROOT}/usr/local/bin/
2929
RUN if [ ! -f $CACHITO_ENV_FILE ]; then go mod download ; fi
3030

3131
# Build manager
32-
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; env ${GO_BUILD_EXTRA_ENV_ARGS} go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager main.go
32+
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; env ${GO_BUILD_EXTRA_ENV_ARGS} go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager cmd/main.go
3333

3434
RUN cp -r templates ${DEST_ROOT}/templates
3535

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ endif
4848

4949
# Set the Operator SDK version to use. By default, what is installed on the system is used.
5050
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
51-
OPERATOR_SDK_VERSION ?= v1.31.0
51+
OPERATOR_SDK_VERSION ?= v1.41.1
5252

5353
# Image URL to use all building/pushing image targets
5454
DEFAULT_IMG ?= quay.io/openstack-k8s-operators/swift-operator:latest
@@ -132,7 +132,7 @@ PROC_CMD = --procs ${PROCS}
132132

133133
.PHONY: test
134134
test: manifests generate fmt vet envtest ginkgo ## Run tests.
135-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) --trace --cover --coverpkg=../../pkg/swift,../../pkg/swiftproxy/../../pkg/swiftring,../../swiftstorage,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./tests/...
135+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) --trace --cover --coverpkg=../../internal/...,../../api/v1beta1/... --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./test/...
136136

137137
.PHONY: gotest
138138
gotest: test
@@ -141,7 +141,7 @@ gotest: test
141141

142142
.PHONY: build
143143
build: generate fmt vet ## Build manager binary.
144-
go build -o bin/manager main.go
144+
go build -o bin/manager cmd/main.go
145145

146146
.PHONY: run
147147
run: export METRICS_PORT?=8080
@@ -150,7 +150,7 @@ run: export PPROF_PORT?=8082
150150
run: export ENABLE_WEBHOOKS?=false
151151
run: manifests generate fmt vet ## Run a controller from your host.
152152
/bin/bash hack/clean_local_webhook.sh
153-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
153+
go run ./cmd/main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
154154

155155
.PHONY: docker-build
156156
docker-build: test ## Build docker image with the manager.
@@ -196,7 +196,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
196196
ENVTEST ?= $(LOCALBIN)/setup-envtest
197197

198198
## Tool Versions
199-
KUSTOMIZE_VERSION ?= v3.8.7
199+
KUSTOMIZE_VERSION ?= v5.6.0
200200
CONTROLLER_TOOLS_VERSION ?= v0.18.0
201201

202202
SETUP_ENVTEST_VERSION ?= release-0.22

PROJECT

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
15
domain: openstack.org
26
layout:
3-
- go.kubebuilder.io/v3
7+
- go.kubebuilder.io/v4
48
plugins:
59
manifests.sdk.operatorframework.io/v2: {}
610
scorecard.sdk.operatorframework.io/v2: {}

api/v1beta1/swift_webhook.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ package v1beta1
1919
import (
2020
"fmt"
2121

22-
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
2322
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
23+
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
2424
apierrors "k8s.io/apimachinery/pkg/api/errors"
2525
"k8s.io/apimachinery/pkg/runtime"
2626
"k8s.io/apimachinery/pkg/runtime/schema"
2727
"k8s.io/apimachinery/pkg/util/validation/field"
28-
ctrl "sigs.k8s.io/controller-runtime"
2928
logf "sigs.k8s.io/controller-runtime/pkg/log"
3029
"sigs.k8s.io/controller-runtime/pkg/webhook"
3130
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
@@ -37,7 +36,7 @@ type SwiftDefaults struct {
3736
ContainerContainerImageURL string
3837
ObjectContainerImageURL string
3938
ProxyContainerImageURL string
40-
ProxyAPITimeout int
39+
ProxyAPITimeout int
4140
}
4241

4342
var swiftDefaults SwiftDefaults
@@ -50,16 +49,6 @@ func SetupSwiftDefaults(defaults SwiftDefaults) {
5049
swiftlog.Info("Swift defaults initialized", "defaults", defaults)
5150
}
5251

53-
func (r *Swift) SetupWebhookWithManager(mgr ctrl.Manager) error {
54-
return ctrl.NewWebhookManagedBy(mgr).
55-
For(r).
56-
Complete()
57-
}
58-
59-
// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
60-
61-
//+kubebuilder:webhook:path=/mutate-swift-openstack-org-v1beta1-swift,mutating=true,failurePolicy=fail,sideEffects=None,groups=swift.openstack.org,resources=swifts,verbs=create;update,versions=v1beta1,name=mswift.kb.io,admissionReviewVersions=v1
62-
6352
var _ webhook.Defaulter = &Swift{}
6453

6554
// Default implements webhook.Defaulter so a webhook will be registered for the type
@@ -102,19 +91,16 @@ func (spec *SwiftSpec) Default() {
10291
spec.SwiftProxy.ContainerImageProxy = swiftDefaults.ProxyContainerImageURL
10392
}
10493

105-
if spec.SwiftProxy.APITimeout == 0 {
106-
spec.SwiftProxy.APITimeout = swiftDefaults.ProxyAPITimeout
107-
}
94+
if spec.SwiftProxy.APITimeout == 0 {
95+
spec.SwiftProxy.APITimeout = swiftDefaults.ProxyAPITimeout
96+
}
10897
}
10998

11099
// Default - set defaults for this Swift core spec (this version is used by OpenStackControlplane webhooks)
111100
func (spec *SwiftSpecCore) Default() {
112101
// nothing here yet
113102
}
114103

115-
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
116-
//+kubebuilder:webhook:path=/validate-swift-openstack-org-v1beta1-swift,mutating=false,failurePolicy=fail,sideEffects=None,groups=swift.openstack.org,resources=swifts,verbs=create;update,versions=v1beta1,name=vswift.kb.io,admissionReviewVersions=v1
117-
118104
var _ webhook.Validator = &Swift{}
119105

120106
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type

api/v1beta1/webhook_suite_test.go

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)