Skip to content

Commit eb16018

Browse files
committed
Upgrade to Operator SDK 1.41.1
This commit upgrades the cinder-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 (Cinder, CinderAPI, etc.) - 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-21923 Assisted-by: claude-4-sonnet Signed-off-by: Martin Schuppert <[email protected]>
1 parent c164f45 commit eb16018

File tree

105 files changed

+1371
-695
lines changed

Some content is hidden

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

105 files changed

+1371
-695
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-cinder-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: cinder
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 }}

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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ endif
5454

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

5959
# Image URL to use all building/pushing image targets
6060
DEFAULT_IMG ?= quay.io/openstack-k8s-operators/cinder-operator:latest
@@ -158,7 +158,6 @@ $(GINKGO): $(LOCALBIN)
158158

159159
.PHONY: test
160160
test: manifests generate fmt vet envtest ginkgo ## Run tests.
161-
go test -v ./pkg/.. ./controllers/.. ./api/.. -coverprofile cover.out
162161
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
163162
$(GINKGO) --trace --cover --coverprofile cover.out --covermode=atomic --randomize-all ${PROC_CMD} $(GINKGO_ARGS) ./test/functional/...
164163

@@ -174,7 +173,7 @@ gowork: ## Generate go.work file to support our multi module repository
174173

175174
.PHONY: build
176175
build: generate fmt vet ## Build manager binary.
177-
go build -o bin/manager main.go
176+
go build -o bin/manager cmd/main.go
178177

179178
.PHONY: run
180179
run: export METRICS_PORT?=8080
@@ -183,7 +182,7 @@ run: export PPROF_PORT?=8082
183182
run: export ENABLE_WEBHOOKS?=false
184183
run: manifests generate fmt vet ## Run a controller from your host.
185184
/bin/bash hack/clean_local_webhook.sh
186-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
185+
go run ./cmd/main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
187186

188187
.PHONY: docker-build
189188
docker-build: test ## Build docker image with the manager.
@@ -249,7 +248,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
249248
ENVTEST ?= $(LOCALBIN)/setup-envtest
250249

251250
## Tool Versions
252-
KUSTOMIZE_VERSION ?= v3.8.7
251+
KUSTOMIZE_VERSION ?= v5.6.0
253252
CONTROLLER_TOOLS_VERSION ?= v0.18.0
254253
GOTOOLCHAIN_VERSION ?= go1.24.0
255254

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ import (
2626

2727
"golang.org/x/exp/maps"
2828

29+
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
2930
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
3031
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
31-
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
3232
apierrors "k8s.io/apimachinery/pkg/api/errors"
3333
"k8s.io/apimachinery/pkg/runtime"
3434
"k8s.io/apimachinery/pkg/runtime/schema"
3535
"k8s.io/apimachinery/pkg/util/validation/field"
36-
ctrl "sigs.k8s.io/controller-runtime"
3736
logf "sigs.k8s.io/controller-runtime/pkg/log"
3837
"sigs.k8s.io/controller-runtime/pkg/webhook"
3938
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
@@ -72,15 +71,6 @@ func SetupDefaults() {
7271
cinderlog.Info("Cinder defaults initialized", "defaults", cinderDefaults)
7372
}
7473

75-
// SetupWebhookWithManager sets up the webhook with the Manager
76-
func (r *Cinder) SetupWebhookWithManager(mgr ctrl.Manager) error {
77-
return ctrl.NewWebhookManagedBy(mgr).
78-
For(r).
79-
Complete()
80-
}
81-
82-
//+kubebuilder:webhook:path=/mutate-cinder-openstack-org-v1beta1-cinder,mutating=true,failurePolicy=fail,sideEffects=None,groups=cinder.openstack.org,resources=cinders,verbs=create;update,versions=v1beta1,name=mcinder.kb.io,admissionReviewVersions=v1
83-
8474
var _ webhook.Defaulter = &Cinder{}
8575

8676
// Default implements webhook.Defaulter so a webhook will be registered for the type
@@ -128,9 +118,6 @@ func (spec *CinderSpecCore) Default() {
128118
spec.CinderSpecBase.Default()
129119
}
130120

131-
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
132-
//+kubebuilder:webhook:path=/validate-cinder-openstack-org-v1beta1-cinder,mutating=false,failurePolicy=fail,sideEffects=None,groups=cinder.openstack.org,resources=cinders,verbs=create;update,versions=v1beta1,name=vcinder.kb.io,admissionReviewVersions=v1
133-
134121
var _ webhook.Validator = &Cinder{}
135122

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

0 commit comments

Comments
 (0)