Skip to content

Commit a272264

Browse files
stuggiopenshift-merge-bot[bot]
authored andcommitted
Upgrade to Operator SDK 1.41.1
This commit upgrades the placement-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-21984 Assisted-by: claude-4-sonnet Signed-off-by: Martin Schuppert <[email protected]>
1 parent 7583889 commit a272264

File tree

98 files changed

+1112
-732
lines changed

Some content is hidden

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

98 files changed

+1112
-732
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-placement-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: placement
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: placement
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: placement
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 }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ repos:
7272
rev: e30d72fcbced0ab8a7b6d23be1dee129e2a7b849
7373
hooks:
7474
- id: kuttl-single-test-assert
75-
args: ["tests/kuttl"]
75+
args: ["test/kuttl"]

Dockerfile

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

2626
# Build manager
27-
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
27+
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
2828

2929
RUN cp -r templates ${DEST_ROOT}/templates
3030

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/placement-operator:latest
@@ -114,13 +114,13 @@ vet: gowork ## Run go vet against code.
114114

115115
.PHONY: test
116116
test: manifests generate gowork fmt vet envtest ginkgo ## Run tests.
117-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" $(GINKGO) --trace --cover --coverpkg=../../pkg/placement,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic --randomize-all $(GINKGO_ARGS) ./tests/...
117+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" $(GINKGO) --trace --cover --coverpkg=../../internal/...,../../api/v1beta1/... --coverprofile cover.out --covermode=atomic --randomize-all $(GINKGO_ARGS) ./test/... ./internal/...
118118

119119
##@ Build
120120

121121
.PHONY: build
122122
build: generate fmt vet ## Build manager binary.
123-
go build -o bin/manager main.go
123+
go build -o bin/manager cmd/main.go
124124

125125
.PHONY: run
126126
run: export METRICS_PORT?=8080
@@ -129,7 +129,7 @@ run: export PPROF_PORT?=8082
129129
run: export ENABLE_WEBHOOKS?=false
130130
run: manifests generate fmt vet ## Run a controller from your host.
131131
/bin/bash hack/clean_local_webhook.sh
132-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
132+
go run ./cmd/main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
133133

134134

135135
# Extra vars which will be passed to the Docker-build
@@ -197,7 +197,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
197197
GINKGO ?= $(LOCALBIN)/ginkgo
198198

199199
## Tool Versions
200-
KUSTOMIZE_VERSION ?= v3.8.7
200+
KUSTOMIZE_VERSION ?= v5.6.0
201201
CONTROLLER_TOOLS_VERSION ?= v0.18.0
202202

203203
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/placementapi_webhook.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"k8s.io/apimachinery/pkg/runtime"
3030
"k8s.io/apimachinery/pkg/runtime/schema"
3131
"k8s.io/apimachinery/pkg/util/validation/field"
32-
ctrl "sigs.k8s.io/controller-runtime"
3332
logf "sigs.k8s.io/controller-runtime/pkg/log"
3433
"sigs.k8s.io/controller-runtime/pkg/webhook"
3534
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
@@ -52,15 +51,6 @@ func SetupPlacementAPIDefaults(defaults PlacementAPIDefaults) {
5251
placementapilog.Info("PlacementAPI defaults initialized", "defaults", defaults)
5352
}
5453

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

6656
// Default implements webhook.Defaulter so a webhook will be registered for the type
@@ -86,9 +76,6 @@ func (spec *PlacementAPISpecCore) Default() {
8676
// nothing here yet
8777
}
8878

89-
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
90-
//+kubebuilder:webhook:path=/validate-placement-openstack-org-v1beta1-placementapi,mutating=false,failurePolicy=fail,sideEffects=None,groups=placement.openstack.org,resources=placementapis,verbs=create;update,versions=v1beta1,name=vplacementapi.kb.io,admissionReviewVersions=v1
91-
9279
var _ webhook.Validator = &PlacementAPI{}
9380

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

0 commit comments

Comments
 (0)