@@ -57,7 +57,7 @@ OPERATOR_SDK_VERSION ?= v1.33.0
57
57
# Image URL to use all building/pushing image targets
58
58
IMG ?= $(REGISTRY ) /$(PROJECT_NAME ) :v$(VERSION )
59
59
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
60
- ENVTEST_K8S_VERSION = 1.26.1
60
+ ENVTEST_K8S_VERSION = 1.26.14
61
61
62
62
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
63
63
ifeq (,$(shell go env GOBIN) )
@@ -293,3 +293,86 @@ catalog-build: opm ## Build a catalog image.
293
293
.PHONY : catalog-push
294
294
catalog-push : # # Push a catalog image.
295
295
$(MAKE ) docker-push IMG=$(CATALOG_IMG )
296
+
297
+ # #@ E2E
298
+
299
+ # kind
300
+ KIND_VERSION ?= v0.22.0
301
+
302
+ KIND_KUBECONFIG ?= ./kind-kubeconfig
303
+ KIND_CLUSTER_NAME ?= ${PROJECT_NAME}
304
+
305
+ .PHONY : kind
306
+ KIND = $(LOCALBIN ) /kind
307
+ kind : # # Download kind locally if necessary.
308
+ ifeq (,$(shell which $(KIND ) ) )
309
+ ifeq (,$(shell which kind 2>/dev/null) )
310
+ @{ \
311
+ set -e ;\
312
+ go install sigs.k8s.io/kind@$(KIND_VERSION) ;\
313
+ }
314
+ KIND = $(GOBIN ) /bin/kind
315
+ else
316
+ KIND = $(shell which kind)
317
+ endif
318
+ endif
319
+
320
+ OLM_VERSION ?= v0.27.0
321
+
322
+ # Create a kind cluster, install ingress-nginx, and wait for it to be available.
323
+ .PHONY : kind-create
324
+ kind-create : kind # # Create a kind cluster.
325
+ $(KIND ) create cluster --config test/e2e/kind-$(ENVTEST_K8S_VERSION ) .yaml --name $(KIND_CLUSTER_NAME ) --kubeconfig $(KIND_KUBECONFIG ) --wait 120s
326
+ make kind-setup KUBECONFIG=$(KIND_KUBECONFIG )
327
+
328
+ .PHONY : kind-setup
329
+ kind-setup : kind # # setup kind cluster base environment
330
+ @echo " \nSetup kind cluster base environment, install ingress-nginx and OLM"
331
+ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
332
+ kubectl -n ingress-nginx wait deployment ingress-nginx-controller --for=condition=available --timeout=300s
333
+ curl -sSL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/$(OLM_VERSION ) /install.sh | bash -s $(OLM_VERSION )
334
+
335
+ .PHONY : kind-delete
336
+ kind-delete : kind # # Delete a kind cluster.
337
+ $(KIND ) delete cluster --name $(KIND_CLUSTER_NAME )
338
+
339
+ # chainsaw
340
+
341
+ CHAINSAW_VERSION ?= v0.1.8
342
+
343
+ .PHONY : chainsaw
344
+ CHAINSAW = $(LOCALBIN ) /chainsaw
345
+ chainsaw : # # Download chainsaw locally if necessary.
346
+ ifeq (,$(shell which $(CHAINSAW ) ) )
347
+ ifeq (,$(shell which chainsaw 2>/dev/null) )
348
+ @{ \
349
+ set -e ;\
350
+ go install github.com/kyverno/chainsaw@$(CHAINSAW_VERSION) ;\
351
+ }
352
+ CHAINSAW = $(GOBIN ) /chainsaw
353
+ else
354
+ CHAINSAW = $(shell which chainsaw)
355
+ endif
356
+ endif
357
+
358
+ # chainsaw setup logical
359
+ # - Build the operator docker image
360
+ # - Load the operator docker image into the kind cluster. When create
361
+ # operator deployment, it will use the image in the kind cluster.
362
+ # - Rebuild the bundle. If override VERSION / REGISTRY or other variables,
363
+ # we need to rebuild the bundle to use the new image, or other changes.
364
+ .PHONY : chainsaw-setup
365
+ chainsaw-setup : manifests kustomize # # Run the chainsaw setup
366
+ @echo " \nSetup chainsaw test environment"
367
+ make docker-build
368
+ $(KIND ) --name $(KIND_CLUSTER_NAME ) load docker-image $(IMG )
369
+ make deploy KUBECONFIG=$(KIND_KUBECONFIG )
370
+
371
+ .PHONY : chainsaw-test
372
+ chainsaw-test : chainsaw # # Run the chainsaw test
373
+ $(CHAINSAW ) test --cluster cluster-1=$(KIND_KUBECONFIG ) --test-dir ./test/e2e
374
+
375
+
376
+ .PHONY : chainsaw-cleanup
377
+ chainsaw-cleanup : manifests kustomize # # Run the chainsaw cleanup
378
+ make undeploy KUBECONFIG=$(KIND_KUBECONFIG )
0 commit comments