5
5
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6
6
VERSION ?= v1.0.0
7
7
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
-
27
- # IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
28
- # This variable is used to construct full image tags for bundle and catalog images.
29
- #
30
- # For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
31
- # clastix.io/operator-bundle:$VERSION and clastix.io/operator-catalog:$VERSION.
32
- IMAGE_TAG_BASE ?= clastix.io/operator
33
-
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:$(VERSION )
37
-
38
8
# Image URL to use all building/pushing image targets
39
9
CONTAINER_REPOSITORY ?= docker.io/clastix/kamaji
40
10
@@ -61,9 +31,9 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
61
31
GINKGO ?= $(LOCALBIN ) /ginkgo
62
32
GOLANGCI_LINT ?= $(LOCALBIN ) /golangci-lint
63
33
HELM ?= $(LOCALBIN ) /helm
64
- KUSTOMIZE ?= $(LOCALBIN ) /kustomize
65
34
KIND ?= $(LOCALBIN ) /kind
66
35
KO ?= $(LOCALBIN ) /ko
36
+ YQ ?= $(LOCALBIN ) /yq
67
37
68
38
all : build
69
39
@@ -90,6 +60,11 @@ ko: $(KO) ## Download ko locally if necessary.
90
60
$(KO ) : $(LOCALBIN )
91
61
test -s
$(LOCALBIN ) /ko
|| GOBIN=
$(LOCALBIN ) go install github.com/google/
[email protected]
92
62
63
+ .PHONY : yq
64
+ yq : $(YQ ) # # Download yq locally if necessary.
65
+ $(YQ ) : $(LOCALBIN )
66
+ test -s
$(LOCALBIN ) /yq
|| GOBIN=
$(LOCALBIN ) go install github.com/mikefarah/yq/
[email protected]
67
+
93
68
.PHONY : helm
94
69
helm : $(HELM ) # # Download helm locally if necessary.
95
70
$(HELM ) : $(LOCALBIN )
@@ -120,13 +95,25 @@ apidocs-gen: $(APIDOCS_GEN) ## Download crdoc locally if necessary.
120
95
$(APIDOCS_GEN ) : $(LOCALBIN )
121
96
test -s $(LOCALBIN ) /crdoc || GOBIN=$(LOCALBIN ) go install fybrik.io/crdoc@latest
122
97
123
- kustomize : # # Download kustomize locally if necessary.
124
- $(call install-kustomize,$(KUSTOMIZE ) ,3.8.7)
125
-
126
98
# #@ Development
127
99
128
- manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
129
- $(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
100
+ rbac : controller-gen yq
101
+ $(CONTROLLER_GEN ) rbac:roleName=manager-role paths=" ./..." output:stdout | $(YQ ) ' .rules' > ./charts/kamaji/controller-gen/clusterrole.yaml
102
+
103
+ webhook : controller-gen yq
104
+ $(CONTROLLER_GEN ) webhook paths=" ./..." output:stdout | $(YQ ) ' select(documentIndex == 0) | .webhooks' > ./charts/kamaji/controller-gen/mutating-webhook.yaml
105
+ $(CONTROLLER_GEN ) webhook paths=" ./..." output:stdout | $(YQ ) ' select(documentIndex == 1) | .webhooks' > ./charts/kamaji/controller-gen/validating-webhook.yaml
106
+ $(YQ ) -i ' map(.clientConfig.service.name |= "{{ include \"kamaji.webhookServiceName\" . }}")' ./charts/kamaji/controller-gen/mutating-webhook.yaml
107
+ $(YQ ) -i ' map(.clientConfig.service.namespace |= "{{ .Release.Namespace }}")' ./charts/kamaji/controller-gen/mutating-webhook.yaml
108
+ $(YQ ) -i ' map(.clientConfig.service.name |= "{{ include \"kamaji.webhookServiceName\" . }}")' ./charts/kamaji/controller-gen/validating-webhook.yaml
109
+ $(YQ ) -i ' map(.clientConfig.service.namespace |= "{{ .Release.Namespace }}")' ./charts/kamaji/controller-gen/validating-webhook.yaml
110
+
111
+ crds : controller-gen yq
112
+ $(CONTROLLER_GEN ) crd webhook paths=" ./..." output:stdout | $(YQ ) ' select(documentIndex == 0)' > ./charts/kamaji/crds/kamaji.clastix.io_datastores.yaml
113
+ $(CONTROLLER_GEN ) crd webhook paths=" ./..." output:stdout | $(YQ ) ' select(documentIndex == 1)' > ./charts/kamaji/crds/kamaji.clastix.io_tenantcontrolplanes.yaml
114
+ $(YQ ) -i ' . *n load("./charts/kamaji/controller-gen/crd-conversion.yaml")' ./charts/kamaji/crds/kamaji.clastix.io_tenantcontrolplanes.yaml
115
+
116
+ manifests : rbac webhook crds # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
130
117
131
118
generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
132
119
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
@@ -207,7 +194,7 @@ build: $(KO)
207
194
KOCACHE=/tmp/ko-cache KO_DOCKER_REPO=${CONTAINER_REPOSITORY} \
208
195
$(KO ) build ./ --bare --tags=$(VERSION ) --local=$(KO_LOCAL ) --push=$(KO_PUSH )
209
196
210
- # #@ Deployment
197
+ # #@ Development
211
198
212
199
metallb :
213
200
kubectl apply -f " https://raw.githubusercontent.com/metallb/metallb/$$ (curl " https://api.github.com/repos/metallb/metallb/releases/latest" | jq -r " .tag_name" )/config/manifests/metallb-native.yaml"
@@ -216,107 +203,20 @@ metallb:
216
203
cat hack/metallb.yaml | sed -E " s|172.19|$$ (docker network inspect -f '{{range .IPAM.Config}}{{.Gateway}}{{end}}' kind | sed -E 's|^([0-9]+\.[0-9]+)\..*$$ |\1|g')|g" | kubectl apply -f -
217
204
218
205
cert-manager :
219
- kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.10.1/cert-manager.yaml
206
+ $(HELM ) repo add bitnami https://charts.bitnami.com/bitnami
207
+ $(HELM ) upgrade --install cert-manager bitnami/cert-manager --namespace certmanager-system --create-namespace --set " installCRDs=true"
220
208
221
- dev : generate manifests uninstall install rbac # # Full installation for development purposes
222
- go fmt ./...
223
-
224
- load : kind build
209
+ load : kind
225
210
$(KIND ) load docker-image --name kamaji ${CONTAINER_REPOSITORY} :${VERSION}
226
211
227
- rbac : manifests kustomize # # Install RBAC into the K8s cluster specified in ~/.kube/config.
228
- $(KUSTOMIZE ) build config/rbac | kubectl apply -f -
229
-
230
- install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
231
- $(KUSTOMIZE ) build config/crd | kubectl apply -f -
232
-
233
- uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
234
- $(KUSTOMIZE ) build config/crd | kubectl delete -f -
235
-
236
- deploy : manifests kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
237
- cd config/manager && $(KUSTOMIZE ) edit set image controller=${CONTAINER_REPOSITORY} :${VERSION}
238
- $(KUSTOMIZE ) build config/default | kubectl apply -f -
239
-
240
- undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config.
241
- $(KUSTOMIZE ) build config/default | kubectl delete -f -
242
-
243
- yaml-installation-file : manifests kustomize # # Create yaml installation file
244
- $(KUSTOMIZE ) build config/default > config/install.yaml
245
-
246
- .PHONY : bundle
247
- bundle : manifests kustomize # # Generate bundle manifests and metadata, then validate generated files.
248
- operator-sdk generate kustomize manifests -q
249
- cd config/manager && $(KUSTOMIZE ) edit set image controller=$(IMG )
250
- $(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
251
- operator-sdk bundle validate ./bundle
252
-
253
- .PHONY : bundle-build
254
- bundle-build : # # Build the bundle image.
255
- docker build -f bundle.Dockerfile -t $(BUNDLE_IMG ) .
256
-
257
- .PHONY : bundle-push
258
- bundle-push : # # Push the bundle image.
259
- $(MAKE ) docker-push IMG=$(BUNDLE_IMG )
260
-
261
- .PHONY : opm
262
- OPM = ./bin/opm
263
- opm : # # Download opm locally if necessary.
264
- ifeq (,$(wildcard $(OPM ) ) )
265
- ifeq (,$(shell which opm 2>/dev/null) )
266
- @{ \
267
- set -e ;\
268
- mkdir -p $(dir $(OPM)) ;\
269
- OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
270
- curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\
271
- chmod +x $(OPM) ;\
272
- }
273
- else
274
- OPM = $(shell which opm)
275
- endif
276
- endif
277
-
278
- # 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).
279
- # These images MUST exist in a registry and be pull-able.
280
- BUNDLE_IMGS ?= $(BUNDLE_IMG )
281
-
282
- # The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
283
- CATALOG_IMG ?= $(IMAGE_TAG_BASE ) -catalog:v$(VERSION )
284
-
285
- # Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
286
- ifneq ($(origin CATALOG_BASE_IMG ) , undefined)
287
- FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG )
288
- endif
289
-
290
- # Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
291
- # This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
292
- # https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
293
- .PHONY : catalog-build
294
- catalog-build : opm # # Build a catalog image.
295
- $(OPM ) index add --container-tool docker --mode semver --tag $(CATALOG_IMG ) --bundles $(BUNDLE_IMGS ) $(FROM_INDEX_OPT )
296
-
297
- # Push the catalog image.
298
- .PHONY : catalog-push
299
- catalog-push : # # Push a catalog image.
300
- $(MAKE ) docker-push IMG=$(CATALOG_IMG )
301
-
302
- define install-kustomize
303
- @[ -f $(1 ) ] || { \
304
- set -e ;\
305
- echo "Installing v$(2 ) " ;\
306
- cd bin ;\
307
- wget "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" ;\
308
- bash ./install_kustomize.sh $(2 ) ;\
309
- }
310
- endef
212
+ # #@ e2e
311
213
312
214
.PHONY : env
313
215
env :
314
216
@make -C deploy/kind kind ingress-nginx
315
217
316
- # #@ e2e
317
-
318
218
.PHONY : e2e
319
- e2e : env load helm ginkgo cert-manager # # Create a KinD cluster, install Kamaji on it and run the test suite.
219
+ e2e : env build load helm ginkgo cert-manager # # Create a KinD cluster, install Kamaji on it and run the test suite.
320
220
$(HELM ) repo add clastix https://clastix.github.io/charts
321
221
$(HELM ) dependency build ./charts/kamaji
322
222
$(HELM ) upgrade --debug --install kamaji ./charts/kamaji --create-namespace --namespace kamaji-system --set " image.pullPolicy=Never" --set " telemetry.disabled=true"
@@ -327,4 +227,4 @@ e2e: env load helm ginkgo cert-manager ## Create a KinD cluster, install Kamaji
327
227
328
228
.PHONY : apidoc
329
229
apidoc : apidocs-gen
330
- $(APIDOCS_GEN ) crdoc --resources config/crd/bases --output docs/content/reference/api.md --template docs/templates/reference-cr.tmpl
230
+ $(APIDOCS_GEN ) crdoc --resources charts/kamaji/crds --output docs/content/reference/api.md --template docs/templates/reference-cr.tmpl
0 commit comments