From 67f39a512d0c246b2e0c4b99614e23bcf42cd43e Mon Sep 17 00:00:00 2001 From: Tim Ebert Date: Sun, 16 Mar 2025 14:00:06 +0100 Subject: [PATCH 1/2] Rename example shard to `checksum-controller` --- .github/workflows/images.yaml | 2 +- .run/shard (kind).run.xml | 8 +- Makefile | 16 +- cmd/{shard => checksum-controller}/main.go | 21 ++- .../reconciler.go | 0 docs/development.md | 30 ++-- docs/getting-started.md | 148 +++++++++--------- docs/implement-sharding.md | 11 +- .../controller}/deployment.yaml | 10 +- .../controller}/kustomization.yaml | 6 +- .../controller}/rbac.yaml | 8 +- .../controller}/serviceaccount.yaml | 2 +- .../controllerring/controllerring.yaml | 2 +- .../controllerring/kustomization.yaml | 0 .../controllerring/sharder_rbac.yaml | 6 +- hack/config/skaffold.yaml | 15 +- 16 files changed, 141 insertions(+), 144 deletions(-) rename cmd/{shard => checksum-controller}/main.go (85%) rename cmd/{shard => checksum-controller}/reconciler.go (100%) rename hack/config/{shard/shard => checksum-controller/controller}/deployment.yaml (71%) rename hack/config/{shard/shard => checksum-controller/controller}/kustomization.yaml (63%) rename hack/config/{shard/shard => checksum-controller/controller}/rbac.yaml (81%) rename hack/config/{shard/shard => checksum-controller/controller}/serviceaccount.yaml (74%) rename hack/config/{shard => checksum-controller}/controllerring/controllerring.yaml (90%) rename hack/config/{shard => checksum-controller}/controllerring/kustomization.yaml (100%) rename hack/config/{shard => checksum-controller}/controllerring/sharder_rbac.yaml (80%) diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index 520fa701..fb75d6cd 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -35,7 +35,7 @@ jobs: # prepare .ko.yaml to inject build settings into all images entrypoints=( ./cmd/sharder - ./cmd/shard + ./cmd/checksum-controller ./webhosting-operator/cmd/experiment ./webhosting-operator/cmd/webhosting-operator ) diff --git a/.run/shard (kind).run.xml b/.run/shard (kind).run.xml index b29c0e82..9688cd3b 100644 --- a/.run/shard (kind).run.xml +++ b/.run/shard (kind).run.xml @@ -1,15 +1,15 @@ - + - + - + - \ No newline at end of file + diff --git a/Makefile b/Makefile index 0015782d..3ee17078 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) TAG ?= latest GHCR_REPO ?= ghcr.io/timebertt/kubernetes-controller-sharding SHARDER_IMG ?= $(GHCR_REPO)/sharder:$(TAG) -SHARD_IMG ?= $(GHCR_REPO)/shard:$(TAG) +CHECKSUM_CONTROLLER_IMG ?= $(GHCR_REPO)/checksum-controller:$(TAG) WEBHOSTING_OPERATOR_IMG ?= $(GHCR_REPO)/webhosting-operator:$(TAG) EXPERIMENT_IMG ?= $(GHCR_REPO)/experiment:$(TAG) @@ -142,12 +142,12 @@ run: $(KUBECTL) generate-fast ## Run the sharder from your host and deploy prere $(KUBECTL) apply --server-side --force-conflicts -k hack/config/certificates/host go run ./cmd/sharder --config=hack/config/sharder/host/config.yaml --zap-log-level=debug -SHARD_NAME ?= shard-$(shell tr -dc bcdfghjklmnpqrstvwxz2456789 /dev/null || kubectl -n default get deploy shard &>/dev/null ; then - echo "Example shard is still running, refusing to run a load test experiment." - echo "Ensure a clean load test environment, i.e., run 'make down SKAFFOLD_MODULE=shard'." + if kubectl get controllerring checksum-controller &>/dev/null || kubectl -n default get deploy checksum-controller &>/dev/null ; then + echo "checksum-controller is still running, refusing to run a load test experiment." + echo "Ensure a clean load test environment, i.e., run 'make down SKAFFOLD_MODULE=checksum-controller'." exit 1 fi From 9c751ad251185ef217020478aa093ded5e8e2abb Mon Sep 17 00:00:00 2001 From: Tim Ebert Date: Sun, 16 Mar 2025 14:16:26 +0100 Subject: [PATCH 2/2] Adapt e2e tests --- test/e2e/e2e_suite_test.go | 4 ++++ test/e2e/example_test.go | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 2c55015a..98256353 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -17,6 +17,7 @@ limitations under the License. package e2e import ( + "context" "testing" "time" @@ -64,5 +65,8 @@ var _ = BeforeSuite(func() { testClient, err = client.New(restConfig, client.Options{Scheme: scheme}) Expect(err).NotTo(HaveOccurred()) + clientContext, clientCancel := context.WithCancel(context.Background()) komega.SetClient(testClient) + komega.SetContext(clientContext) + DeferCleanup(clientCancel) }) diff --git a/test/e2e/example_test.go b/test/e2e/example_test.go index f19b3667..18959d38 100644 --- a/test/e2e/example_test.go +++ b/test/e2e/example_test.go @@ -32,12 +32,10 @@ import ( . "github.com/timebertt/kubernetes-controller-sharding/pkg/utils/test/matchers" ) -var _ = Describe("Example Shard", Label("example"), Ordered, func() { - const controllerRingName = "example" +var _ = Describe("Example Controller", Label("checksum-controller"), Ordered, func() { + const controllerRingName = "checksum-controller" - var ( - controllerRing *shardingv1alpha1.ControllerRing - ) + var controllerRing *shardingv1alpha1.ControllerRing BeforeAll(func() { controllerRing = &shardingv1alpha1.ControllerRing{ObjectMeta: metav1.ObjectMeta{Name: controllerRingName}} @@ -45,7 +43,7 @@ var _ = Describe("Example Shard", Label("example"), Ordered, func() { Describe("setup", func() { It("the Deployment should be healthy", func(ctx SpecContext) { - deployment := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "shard", Namespace: metav1.NamespaceDefault}} + deployment := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: controllerRingName, Namespace: metav1.NamespaceDefault}} Eventually(ctx, func(g Gomega) { g.Expect(Get(deployment)()).To(Succeed())