@@ -131,15 +131,30 @@ help: ## Display this help.
131131
132132# #@ Development
133133
134+ # (dprince) FIXME: controller-gen crd didn't seem to like multiple paths so I didn't split it. So we can continue using kubebuilder
135+ # I did split out the rbac for both binaries so we can use separate roles
134136.PHONY : manifests
135137manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
136- $(CONTROLLER_GEN ) rbac:roleName=manager-role crd$(CRDDESC_OVERRIDE ) webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases && \
138+ mkdir -p config/operator/rbac && \
139+ $(CONTROLLER_GEN ) crd$(CRDDESC_OVERRIDE ) output:crd:artifacts:config=config/crd/bases webhook paths=" ./..." && \
140+ $(CONTROLLER_GEN ) rbac:roleName=manager-role paths=" {./apis/client/...,./apis/core/...,./apis/dataplane/...,./controllers/client/...,./controllers/core/...,./controllers/dataplane/...,./pkg/...}" output:dir=config/rbac && \
141+ $(CONTROLLER_GEN ) rbac:roleName=operator-role paths=" ./controllers/operator/..." paths=" ./apis/operator/..." output:dir=config/operator/rbac && \
137142 rm -f apis/bases/* && cp -a config/crd/bases apis/
138143
139144.PHONY : generate
140145generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
141146 $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
142147
148+ .PHONY : bindata
149+ bindata : kustomize yq # # Build docker image with the manager.
150+ mkdir -p bindata/crds bindata/rbac bindata/operator
151+ $(KUSTOMIZE ) build config/crd > bindata/crds/crds.yaml
152+ $(KUSTOMIZE ) build config/default > bindata/operator/operator.yaml
153+ cp config/operator/managers.yaml bindata/operator/
154+ cp config/operator/rabbit.yaml bindata/operator/
155+ $(KUSTOMIZE ) build config/rbac > bindata/rbac/rbac.yaml
156+ /bin/bash hack/sync-bindata.sh
157+
143158.PHONY : fmt
144159fmt : # # Run go fmt against code.
145160 go fmt ./...
@@ -196,6 +211,7 @@ cover: test ## Run tests and display functional test coverage
196211.PHONY : build
197212build : generate fmt vet # # Build manager binary.
198213 go build -o bin/manager main.go
214+ go build -o bin/operator cmd/operator/main.go
199215
200216.PHONY : run
201217run : export METRICS_PORT?=8080
@@ -206,8 +222,18 @@ run: manifests generate fmt vet ## Run a controller from your host.
206222 source hack/export_related_images.sh && \
207223 go run ./main.go -metrics-bind-address " :$( METRICS_PORT) " -health-probe-bind-address " :$( HEALTH_PORT) "
208224
225+ .PHONY : run-operator
226+ run-operator : export METRICS_PORT?=8080
227+ run-operator : export HEALTH_PORT?=8081
228+ run-operator : export ENABLE_WEBHOOKS?=false
229+ run-operator : export BASE_BINDATA?=bindata
230+ run-operator : export OPERATOR_IMAGE_URL=${IMG}
231+ run-operator : manifests generate fmt vet # # Run a controller from your host.
232+ source hack/export_operator_related_images.sh && \
233+ go run ./cmd/operator/main.go -metrics-bind-address " :$( METRICS_PORT) " -health-probe-bind-address " :$( HEALTH_PORT) "
234+
209235.PHONY : docker-build
210- docker-build : # # Build docker image with the manager.
236+ docker-build : # # Build docker image with the manager.
211237 podman build -t ${IMG} . ${DOCKER_BUILD_ARGS}
212238
213239.PHONY : docker-push
@@ -272,7 +298,7 @@ GINKGO_TESTS ?= ./tests/... ./apis/client/... ./apis/core/... ./apis/dataplane/.
272298KUTTL ?= $(LOCALBIN ) /kubectl-kuttl
273299
274300# # Tool Versions
275- KUSTOMIZE_VERSION ?= v3.8.7
301+ KUSTOMIZE_VERSION ?= v5.5.0 # (dprince: bumped to aquire new features like --load-restrictor)
276302CONTROLLER_TOOLS_VERSION ?= v0.14.0
277303CRD_MARKDOWN_VERSION ?= v0.0.3
278304KUTTL_VERSION ?= 0.17.0
@@ -340,11 +366,10 @@ endif
340366.PHONY : bundle
341367bundle : build manifests kustomize operator-sdk # # Generate bundle manifests and metadata, then validate generated files.
342368 $(OPERATOR_SDK ) generate kustomize manifests -q
343- cd config/manager && \
344- $(KUSTOMIZE ) edit set image controller=$(IMG ) && \
345- $(KUSTOMIZE ) edit add patch --kind Deployment --name controller-manager --namespace system --patch " [{\" op\" : \" replace\" , \" path\" : \" /spec/template/spec/containers/0/env/0\" , \" value\" : {\" name\" : \" OPENSTACK_RELEASE_VERSION\" , \" value\" : \" $( OPENSTACK_RELEASE_VERSION) \" }}]"
346- $(KUSTOMIZE ) build config/manifests | $(OPERATOR_SDK ) generate bundle $(BUNDLE_GEN_FLAGS )
347- cp dependencies.yaml ./bundle/metadata
369+ cd config/operator/deployment/ && $(KUSTOMIZE ) edit set image controller=$(IMG ) && \
370+ $(KUSTOMIZE ) edit add patch --kind Deployment --name openstack-operator-controller-operator --namespace system --patch " [{\" op\" : \" replace\" , \" path\" : \" /spec/template/spec/containers/0/env/0\" , \" value\" : {\" name\" : \" OPENSTACK_RELEASE_VERSION\" , \" value\" : \" $( OPENSTACK_RELEASE_VERSION) \" }}]" && \
371+ $(KUSTOMIZE ) edit add patch --kind Deployment --name openstack-operator-controller-operator --namespace system --patch " [{\" op\" : \" replace\" , \" path\" : \" /spec/template/spec/containers/0/env/1\" , \" value\" : {\" name\" : \" OPERATOR_IMAGE_URL\" , \" value\" : \" $( IMG) \" }}]"
372+ $(KUSTOMIZE ) build config/operator --load-restrictor=' LoadRestrictionsNone' | $(OPERATOR_SDK ) generate bundle $(BUNDLE_GEN_FLAGS )
348373 $(OPERATOR_SDK ) bundle validate ./bundle
349374
350375.PHONY : bundle-build
0 commit comments