Skip to content

Commit e95cd7f

Browse files
authored
feat: massive operator refactor (#289)
* update operator dependencies and align with latest kubebuilder format; bugfixes * lint fixes * fix makefile targets * regenerate chart and fix lint issues
1 parent 55ac314 commit e95cd7f

File tree

112 files changed

+2609
-1672
lines changed

Some content is hidden

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

112 files changed

+2609
-1672
lines changed

.goreleaser.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ dist: "dist"
88
builds:
99
- env: [CGO_ENABLED=0]
1010
mod_timestamp: '{{ .CommitTimestamp }}'
11+
main: cmd/main.go
1112
goos:
1213
- linux
1314
goarch:
1415
- amd64
16+
- arm64
1517

1618
source:
1719
enabled: true

Makefile

Lines changed: 30 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,13 @@
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
66
VERSION ?= 0.0.1
77

8-
# CHANNELS define the bundle channels used in the bundle.
9-
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
10-
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
11-
# - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate,fast,stable)
12-
# - use environment variables to overwrite this value (e.g export CHANNELS="candidate,fast,stable")
13-
ifneq ($(origin CHANNELS), undefined)
14-
BUNDLE_CHANNELS := --channels=$(CHANNELS)
15-
endif
16-
17-
# DEFAULT_CHANNEL defines the default channel used in the bundle.
18-
# Add a new line here if you would like to change its default config. (E.g DEFAULT_CHANNEL = "stable")
19-
# To re-generate a bundle for any other default channel without changing the default setup, you can:
20-
# - use the DEFAULT_CHANNEL as arg of the bundle target (e.g make bundle DEFAULT_CHANNEL=stable)
21-
# - use environment variables to overwrite this value (e.g export DEFAULT_CHANNEL="stable")
22-
ifneq ($(origin DEFAULT_CHANNEL), undefined)
23-
BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
24-
endif
25-
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
26-
278
# IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
289
# This variable is used to construct full image tags for bundle and catalog images.
2910
#
3011
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
3112
# armadaproject.io/armada-operator-bundle:$VERSION and armadaproject.io/armada-operator-catalog:$VERSION.
3213
IMAGE_TAG_BASE ?= armadaproject.io/armada-operator
3314

34-
# BUNDLE_IMG defines the image:tag used for the bundle.
35-
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
36-
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
37-
38-
# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
39-
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
40-
41-
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
42-
# You can enable this value if you would like to use SHA Based Digests
43-
# To enable set flag to true
44-
USE_IMAGE_DIGESTS ?= false
45-
ifeq ($(USE_IMAGE_DIGESTS), true)
46-
BUNDLE_GEN_FLAGS += --use-image-digests
47-
endif
48-
4915
# Image URL to use all building/pushing image targets
5016
IMG ?= armada-operator:latest
5117
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
@@ -119,22 +85,24 @@ lint-fix:
11985

12086
.PHONY: test
12187
test: manifests generate fmt vet gotestsum ## Run tests.
122-
$(GOTESTSUM) -- ./controllers/... -coverprofile operator.out
88+
$(GOTESTSUM) -- ./internal/controller/... -coverprofile operator.out
12389

12490
.PHONY: test-integration
12591
test-integration: manifests generate fmt vet gotestsum envtest ## Run integration tests.
126-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GOTESTSUM) -- ./test/... ./apis/...
92+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GOTESTSUM) -- ./test/... ./api/...
93+
12794
.PHONY: kind-create
12895
kind-create: kind
12996
kind create cluster --config hack/kind-config.yaml
97+
13098
.PHONY: test-e2e
13199
test-e2e: kind docker-build install-cert-manager
132100
kind load docker-image controller:latest
133101

134102
# Integration test without Ginkgo colorized output and control chars, for logging purposes
135103
.PHONY: test-integration-debug
136104
test-integration-debug: manifests generate fmt vet gotestsum envtest ## Run integration tests.
137-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -v ./test/... ./apis/... --coverprofile integration.out -args --ginkgo.no-color
105+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -v ./test/... ./api/... --coverprofile integration.out -args --ginkgo.no-color
138106

139107
##@ Build
140108

@@ -144,7 +112,10 @@ build: generate fmt vet ## Build manager binary.
144112

145113
.PHONY: run
146114
run: manifests generate fmt vet ## Run a controller from your host.
147-
go run ./main.go
115+
go run ./cmd/main.go
116+
117+
run-no-webhook: manifests generate fmt vet ## Run a controller from your host without webhooks.
118+
ENABLE_WEBHOOKS=false go run ./cmd/main.go
148119

149120
# Go Release Build
150121
.PHONY: go-release-build
@@ -154,7 +125,7 @@ go-release-build: goreleaser
154125
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
155126
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
156127
.PHONY: docker-build
157-
docker-build: test ## Build docker image with the manager.
128+
docker-build: ## Build docker image with the manager.
158129
docker build -t ${IMG} .
159130

160131
.PHONY: docker-push
@@ -211,7 +182,8 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
211182

212183
.PHONY: generate-helm-chart
213184
generate-helm-chart: manifests kustomize helmify
214-
$(KUSTOMIZE) build config/default | $(HELMIFY) -crd-dir deployment/armada-operator
185+
$(KUSTOMIZE) build config/default | $(HELMIFY) -crd-dir charts/armada-operator
186+
./hack/fix-helmify.sh
215187

216188
## Kubernetes Dependencies
217189
CERT_MANAGER_MANIFEST ?= "https://github.com/cert-manager/cert-manager/releases/download/v1.6.3/cert-manager.yaml"
@@ -231,30 +203,24 @@ install-ingress-controller:
231203
uninstall-ingress-controller:
232204
kubectl delete -f ${INGRESS_MANIFEST}
233205

234-
PULSAR_IMAGE="apachepulsar/pulsar"
235-
ifeq ($(ARCH), arm64)
236-
PULSAR_IMAGE="richgross/pulsar:2.11.0"
237-
endif
238-
.PHONY: install-pulsar
239-
install-pulsar:
240-
docker pull $(PULSAR_IMAGE)
241-
kind load docker-image --name $(KIND_DEV_CLUSTER_NAME) $(PULSAR_IMAGE)
242-
cat dev/manifests/pulsar.yaml | PULSAR_IMAGE=$(PULSAR_IMAGE) envsubst | kubectl apply -n armada -f -
243-
244-
.PHONY: helm-bitnami
245-
helm-bitnami: helm
206+
.PHONY: helm-repos
207+
helm-repos: helm
246208
$(HELM) repo add bitnami https://charts.bitnami.com/bitnami
209+
$(HELM) repo add apache https://pulsar.apache.org/charts
210+
$(HELM) repo add dandydev https://dandydeveloper.github.io/charts
247211
$(HELM) repo update
248212

213+
.PHONY: install-pulsar
214+
install-pulsar: helm-repos
215+
$(HELM) install pulsar apache/pulsar -f dev/quickstart/pulsar.values.yaml --namespace data
216+
249217
.PHONY: helm-install-postgres
250-
helm-install-postgres: helm-bitnami
251-
docker pull postgres:15.2-alpine
252-
kind load docker-image --name $(KIND_DEV_CLUSTER_NAME) postgres:15.2-alpine
253-
$(HELM) install postgresql -n armada -f ./dev/helm-charts/postgres_bitnami_values.yaml bitnami/postgresql
218+
helm-install-postgres: helm-repos
219+
helm install postgres bitnami/postgresql -f dev/quickstart/postgres.values.yaml --create-namespace --namespace data
254220

255221
.PHONY: helm-install-redis
256-
helm-install-redis: helm-bitnami
257-
$(HELM) install redis -n armada -f ./dev/helm-charts/redis_bitnami_values.yaml bitnami/redis
222+
helm-install-redis: helm-repos
223+
$(HELM) install redis dandydev/redis-ha -f dev/quickstart/redis.values.yaml --create-namespace --namespace data
258224

259225
PROMETHEUS_OPERATOR_VERSION=v0.62.0
260226
.PHONY: dev-install-prometheus-operator
@@ -282,7 +248,7 @@ HELMIFY ?= $(LOCALBIN)/helmify
282248
GORELEASER ?= $(LOCALBIN)/goreleaser
283249
## Tool Versions
284250
KUSTOMIZE_VERSION ?= v4.5.7
285-
CONTROLLER_TOOLS_VERSION ?= v0.10.0
251+
CONTROLLER_TOOLS_VERSION ?= v0.13.0
286252

287253
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
288254
.PHONY: kustomize
@@ -303,7 +269,7 @@ $(ENVTEST): $(LOCALBIN)
303269
.PHONY: gotestsum
304270
gotestsum: $(GOTESTSUM) ## Download gotestsum locally if necessary.
305271
$(GOTESTSUM): $(LOCALBIN)
306-
test -s $(LOCALBIN)/gotestsum || GOBIN=$(LOCALBIN) go install gotest.tools/gotestsum@v1.8.2
272+
test -s $(LOCALBIN)/gotestsum || GOBIN=$(LOCALBIN) go install gotest.tools/gotestsum@v1.11.0
307273

308274
.PHONY: mockgen
309275
mockgen: $(MOCKGEN) ## Download mockgen locally if necessary.
@@ -318,69 +284,12 @@ $(KIND): $(LOCALBIN)
318284
.PHONY: helmify
319285
helmify: $(HELMIFY)
320286
$(HELMIFY): $(LOCALBIN)
321-
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@v0.3.22
287+
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@v0.4.6
322288

323289
.PHONY: goreleaser
324290
goreleaser: $(GORELEASER)
325291
$(GORELEASER): $(LOCALBIN)
326-
test -s $(LOCALBIN)/goreleaser || GOBIN=$(LOCALBIN) go install github.com/goreleaser/goreleaser@v1.18.1
327-
328-
329-
.PHONY: bundle
330-
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
331-
operator-sdk generate kustomize manifests -q
332-
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
333-
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle $(BUNDLE_GEN_FLAGS)
334-
operator-sdk bundle validate ./bundle
335-
336-
.PHONY: bundle-build
337-
bundle-build: ## Build the bundle image.
338-
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
339-
340-
.PHONY: bundle-push
341-
bundle-push: ## Push the bundle image.
342-
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
343-
344-
.PHONY: opm
345-
OPM = ./bin/opm
346-
opm: ## Download opm locally if necessary.
347-
ifeq (,$(wildcard $(OPM)))
348-
ifeq (,$(shell which opm 2>/dev/null))
349-
@{ \
350-
set -e ;\
351-
mkdir -p $(dir $(OPM)) ;\
352-
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
353-
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\
354-
chmod +x $(OPM) ;\
355-
}
356-
else
357-
OPM = $(shell which opm)
358-
endif
359-
endif
360-
361-
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
362-
# These images MUST exist in a registry and be pull-able.
363-
BUNDLE_IMGS ?= $(BUNDLE_IMG)
364-
365-
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
366-
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
367-
368-
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
369-
ifneq ($(origin CATALOG_BASE_IMG), undefined)
370-
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
371-
endif
372-
373-
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
374-
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
375-
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
376-
.PHONY: catalog-build
377-
catalog-build: opm ## Build a catalog image.
378-
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
379-
380-
# Push the catalog image.
381-
.PHONY: catalog-push
382-
catalog-push: ## Push a catalog image.
383-
$(MAKE) docker-push IMG=$(CATALOG_IMG)
292+
test -s $(LOCALBIN)/goreleaser || GOBIN=$(LOCALBIN) go install github.com/goreleaser/goreleaser@v1.21.2
384293

385294
.PHONY: helm
386295
HELM = ./bin/helm
@@ -415,8 +324,8 @@ create-dev-cluster:
415324

416325
# Setup dependencies for a local development environment
417326
.PHONY: dev-setup
418-
dev-setup: create-dev-cluster install-pulsar helm-install-postgres \
419-
helm-install-redis dev-install-prometheus-operator \
327+
dev-setup: dev-install-prometheus-operator install-pulsar \
328+
helm-install-redis helm-install-postgres \
420329
install-cert-manager install-ingress-controller dev-setup-webhook-tls
421330

422331
.PHONY: dev-install-controller

PROJECT

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
domain: armadaproject.io
22
layout:
3-
- go.kubebuilder.io/v4-alpha
3+
- go.kubebuilder.io/v4
44
multigroup: true
55
plugins:
66
manifests.sdk.operatorframework.io/v2: {}
@@ -15,7 +15,7 @@ resources:
1515
domain: armadaproject.io
1616
group: install
1717
kind: Server
18-
path: github.com/armadaproject/armada-operator/apis/install/v1alpha1
18+
path: github.com/armadaproject/armada-operator/api/install/v1alpha1
1919
version: v1alpha1
2020
webhooks:
2121
defaulting: true
@@ -28,7 +28,7 @@ resources:
2828
domain: armadaproject.io
2929
group: install
3030
kind: Executor
31-
path: github.com/armadaproject/armada-operator/apis/install/v1alpha1
31+
path: github.com/armadaproject/armada-operator/api/install/v1alpha1
3232
version: v1alpha1
3333
webhooks:
3434
defaulting: true
@@ -41,7 +41,7 @@ resources:
4141
domain: armadaproject.io
4242
group: install
4343
kind: Binoculars
44-
path: github.com/armadaproject/armada-operator/apis/install/v1alpha1
44+
path: github.com/armadaproject/armada-operator/api/install/v1alpha1
4545
version: v1alpha1
4646
webhooks:
4747
defaulting: true
@@ -54,7 +54,7 @@ resources:
5454
domain: armadaproject.io
5555
group: install
5656
kind: Lookout
57-
path: github.com/armadaproject/armada-operator/apis/install/v1alpha1
57+
path: github.com/armadaproject/armada-operator/api/install/v1alpha1
5858
version: v1alpha1
5959
webhooks:
6060
defaulting: true
@@ -67,7 +67,7 @@ resources:
6767
domain: armadaproject.io
6868
group: core
6969
kind: Queue
70-
path: github.com/armadaproject/armada-operator/apis/core/v1alpha1
70+
path: github.com/armadaproject/armada-operator/api/core/v1alpha1
7171
version: v1alpha1
7272
- api:
7373
crdVersion: v1
@@ -76,7 +76,7 @@ resources:
7676
domain: armadaproject.io
7777
group: install
7878
kind: EventIngester
79-
path: github.com/armadaproject/armada-operator/apis/install/v1alpha1
79+
path: github.com/armadaproject/armada-operator/api/install/v1alpha1
8080
version: v1alpha1
8181
webhooks:
8282
defaulting: true
@@ -89,7 +89,7 @@ resources:
8989
domain: armadaproject.io
9090
group: install
9191
kind: LookoutIngester
92-
path: github.com/armadaproject/armada-operator/apis/install/v1alpha1
92+
path: github.com/armadaproject/armada-operator/api/install/v1alpha1
9393
version: v1alpha1
9494
webhooks:
9595
defaulting: true
@@ -102,7 +102,7 @@ resources:
102102
domain: armadaproject.io
103103
group: install
104104
kind: SchedulerIngester
105-
path: github.com/armadaproject/armada-operator/apis/install/v1alpha1
105+
path: github.com/armadaproject/armada-operator/api/install/v1alpha1
106106
version: v1alpha1
107107
webhooks:
108108
defaulting: true
@@ -115,7 +115,7 @@ resources:
115115
domain: armadaproject.io
116116
group: install
117117
kind: Scheduler
118-
path: github.com/armadaproject/armada-operator/apis/install/v1alpha1
118+
path: github.com/armadaproject/armada-operator/api/install/v1alpha1
119119
version: v1alpha1
120120
webhooks:
121121
defaulting: true

0 commit comments

Comments
 (0)