Skip to content

Commit 2b0980b

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-21981 Assisted-by: claude-4-sonnet Signed-off-by: Martin Schuppert <[email protected]>
1 parent e42b126 commit 2b0980b

File tree

214 files changed

+1515
-664
lines changed

Some content is hidden

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

214 files changed

+1515
-664
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-ovn-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: ovn
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: ovn
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: ovn
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
@@ -28,7 +28,7 @@ RUN mkdir -p ${DEST_ROOT}/usr/local/bin/
2828
RUN if [ ! -f $CACHITO_ENV_FILE ]; then go mod download ; fi
2929

3030
# Build manager
31-
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
31+
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
3232

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

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/ovn-operator:latest
@@ -129,13 +129,13 @@ PROC_CMD = --procs ${PROCS}
129129

130130
.PHONY: test
131131
test: manifests generate fmt vet envtest ginkgo ## Run tests.
132-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" OPERATOR_TEMPLATES="$(shell pwd)/templates" $(GINKGO) --trace --cover --coverpkg=../../pkg/ovndbcluster,../../pkg/ovnnorthd,../../pkg/ovncontroller,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic --randomize-all ${PROC_CMD} $(GINKGO_ARGS) ./tests/...
132+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" OPERATOR_TEMPLATES="$(shell pwd)/templates" $(GINKGO) --trace --cover --coverpkg=../../internal/...,../../api/v1beta1/... --coverprofile cover.out --covermode=atomic --randomize-all ${PROC_CMD} $(GINKGO_ARGS) ./test/...
133133

134134
##@ Build
135135

136136
.PHONY: build
137137
build: generate fmt vet ## Build manager binary.
138-
go build -o bin/manager main.go
138+
go build -o bin/manager cmd/main.go
139139

140140
.PHONY: run
141141
run: export METRICS_PORT?=8080
@@ -145,7 +145,7 @@ run: export WEBHOOK_PORT?=9443
145145
run: export ENABLE_WEBHOOKS?=false
146146
run: manifests generate fmt vet ## Run a controller from your host.
147147
/bin/bash hack/clean_local_webhook.sh
148-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)" -webhook-bind-address "$(WEBHOOK_PORT)"
148+
go run ./cmd/main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)" -webhook-bind-address "$(WEBHOOK_PORT)"
149149

150150
.PHONY: docker-build
151151
docker-build: test ## Build docker image with the manager.
@@ -209,7 +209,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
209209
GINKGO ?= $(LOCALBIN)/ginkgo
210210

211211
## Tool Versions
212-
KUSTOMIZE_VERSION ?= v3.8.7
212+
KUSTOMIZE_VERSION ?= v5.6.0
213213
CONTROLLER_TOOLS_VERSION ?= v0.18.0
214214

215215
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"

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/ovncontroller_webhook.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2021
"k8s.io/apimachinery/pkg/runtime"
22+
"k8s.io/apimachinery/pkg/runtime/schema"
2123
"k8s.io/apimachinery/pkg/util/validation/field"
22-
ctrl "sigs.k8s.io/controller-runtime"
2324
logf "sigs.k8s.io/controller-runtime/pkg/log"
2425
"sigs.k8s.io/controller-runtime/pkg/webhook"
2526
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
26-
apierrors "k8s.io/apimachinery/pkg/api/errors"
27-
"k8s.io/apimachinery/pkg/runtime/schema"
2827
)
2928

3029
// OVNControllerDefaults -
@@ -45,14 +44,6 @@ func SetupOVNControllerDefaults(defaults OVNControllerDefaults) {
4544
ovncontrollerlog.Info("OVNController defaults initialized", "defaults", defaults)
4645
}
4746

48-
func (r *OVNController) SetupWebhookWithManager(mgr ctrl.Manager) error {
49-
return ctrl.NewWebhookManagedBy(mgr).
50-
For(r).
51-
Complete()
52-
}
53-
54-
//+kubebuilder:webhook:path=/mutate-ovn-openstack-org-v1beta1-ovncontroller,mutating=true,failurePolicy=fail,sideEffects=None,groups=ovn.openstack.org,resources=ovncontrollers,verbs=create;update,versions=v1beta1,name=movncontroller.kb.io,admissionReviewVersions=v1
55-
5647
var _ webhook.Defaulter = &OVNController{}
5748

5849
// Default implements webhook.Defaulter so a webhook will be registered for the type
@@ -81,8 +72,6 @@ func (spec *OVNControllerSpecCore) Default() {
8172
// nothing here yet
8273
}
8374

84-
//+kubebuilder:webhook:path=/validate-ovn-openstack-org-v1beta1-ovncontroller,mutating=false,failurePolicy=fail,sideEffects=None,groups=ovn.openstack.org,resources=ovncontrollers,verbs=create;update,versions=v1beta1,name=vovncontroller.kb.io,admissionReviewVersions=v1
85-
8675
var _ webhook.Validator = &OVNController{}
8776

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

api/v1beta1/ovndbcluster_webhook.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"k8s.io/apimachinery/pkg/runtime"
2828
"k8s.io/apimachinery/pkg/runtime/schema"
2929
"k8s.io/apimachinery/pkg/util/validation/field"
30-
ctrl "sigs.k8s.io/controller-runtime"
3130
logf "sigs.k8s.io/controller-runtime/pkg/log"
3231
"sigs.k8s.io/controller-runtime/pkg/webhook"
3332
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
@@ -51,15 +50,6 @@ func SetupOVNDBClusterDefaults(defaults OVNDBClusterDefaults) {
5150
ovndbclusterlog.Info("OVNDBCluster defaults initialized", "defaults", defaults)
5251
}
5352

54-
// SetupWebhookWithManager sets up the webhook with the Manager
55-
func (r *OVNDBCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
56-
return ctrl.NewWebhookManagedBy(mgr).
57-
For(r).
58-
Complete()
59-
}
60-
61-
//+kubebuilder:webhook:path=/mutate-ovn-openstack-org-v1beta1-ovndbcluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=ovn.openstack.org,resources=ovndbclusters,verbs=create;update,versions=v1beta1,name=movndbcluster.kb.io,admissionReviewVersions=v1
62-
6353
var _ webhook.Defaulter = &OVNDBCluster{}
6454

6555
// Default implements webhook.Defaulter so a webhook will be registered for the type
@@ -89,9 +79,6 @@ func (spec *OVNDBClusterSpecCore) Default() {
8979
// nothing here yet
9080
}
9181

92-
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
93-
//+kubebuilder:webhook:path=/validate-ovn-openstack-org-v1beta1-ovndbcluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=ovn.openstack.org,resources=ovndbclusters,verbs=create;update,versions=v1beta1,name=vovndbcluster.kb.io,admissionReviewVersions=v1
94-
9582
var _ webhook.Validator = &OVNDBCluster{}
9683

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

api/v1beta1/ovnnorthd_webhook.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ limitations under the License.
2323
package v1beta1
2424

2525
import (
26+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2627
"k8s.io/apimachinery/pkg/runtime"
27-
ctrl "sigs.k8s.io/controller-runtime"
28+
"k8s.io/apimachinery/pkg/runtime/schema"
29+
"k8s.io/apimachinery/pkg/util/validation/field"
2830
logf "sigs.k8s.io/controller-runtime/pkg/log"
2931
"sigs.k8s.io/controller-runtime/pkg/webhook"
3032
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
31-
"k8s.io/apimachinery/pkg/util/validation/field"
32-
apierrors "k8s.io/apimachinery/pkg/api/errors"
33-
"k8s.io/apimachinery/pkg/runtime/schema"
3433
)
3534

3635
// OVNNorthdDefaults -
@@ -50,15 +49,6 @@ func SetupOVNNorthdDefaults(defaults OVNNorthdDefaults) {
5049
ovndbclusterlog.Info("OVNNorthd defaults initialized", "defaults", defaults)
5150
}
5251

53-
// SetupWebhookWithManager sets up the webhook with the Manager
54-
func (r *OVNNorthd) SetupWebhookWithManager(mgr ctrl.Manager) error {
55-
return ctrl.NewWebhookManagedBy(mgr).
56-
For(r).
57-
Complete()
58-
}
59-
60-
//+kubebuilder:webhook:path=/mutate-ovn-openstack-org-v1beta1-ovnnorthd,mutating=true,failurePolicy=fail,sideEffects=None,groups=ovn.openstack.org,resources=ovnnorthds,verbs=create;update,versions=v1beta1,name=movnnorthd.kb.io,admissionReviewVersions=v1
61-
6252
var _ webhook.Defaulter = &OVNNorthd{}
6353

6454
// Default implements webhook.Defaulter so a webhook will be registered for the type
@@ -84,9 +74,6 @@ func (spec *OVNNorthdSpecCore) Default() {
8474
// nothing here yet
8575
}
8676

87-
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
88-
//+kubebuilder:webhook:path=/validate-ovn-openstack-org-v1beta1-ovnnorthd,mutating=false,failurePolicy=fail,sideEffects=None,groups=ovn.openstack.org,resources=ovnnorthds,verbs=create;update,versions=v1beta1,name=vovnnorthd.kb.io,admissionReviewVersions=v1
89-
9077
var _ webhook.Validator = &OVNNorthd{}
9178

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

0 commit comments

Comments
 (0)