From 0c1215a033da8d7e915e7a73fcca34f7513a463b Mon Sep 17 00:00:00 2001 From: lorenz <stu203404@mail.uni-kiel.de> Date: Thu, 18 Mar 2021 17:57:04 +0100 Subject: [PATCH] Its working now --- .../benchmark/BenchmarkExecution.kt | 1 + .../benchmark/DonableTestResource.kt | 8 ---- .../theodolite/benchmark/TestResource.kt | 6 --- .../theodolite/benchmark/TestResourceList.kt | 5 --- .../kotlin/theodolite/benchmark/TestSpec.kt | 7 ---- ...teCRDExecutor.kt => TheodoliteOperator.kt} | 41 +++++++++---------- .../theodolite/util/ConfigurationOverride.kt | 3 ++ .../theodolite/util/PatcherDefinition.kt | 3 ++ .../yaml/{testResource.yaml => resource.yaml} | 5 ++- 9 files changed, 30 insertions(+), 49 deletions(-) delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/benchmark/DonableTestResource.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestResource.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestResourceList.kt delete mode 100644 theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestSpec.kt rename theodolite-quarkus/src/main/kotlin/theodolite/execution/{TheodoliteCRDExecutor.kt => TheodoliteOperator.kt} (55%) rename theodolite-quarkus/src/main/resources/yaml/{testResource.yaml => resource.yaml} (51%) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt index 7510fd821..21d9d53cf 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/BenchmarkExecution.kt @@ -6,6 +6,7 @@ import io.fabric8.kubernetes.client.CustomResource import theodolite.util.ConfigurationOverride import kotlin.properties.Delegates +@JsonDeserialize class BenchmarkExecution : CustomResource(){ lateinit var name: String lateinit var benchmark: String diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/DonableTestResource.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/DonableTestResource.kt deleted file mode 100644 index 3c399a76b..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/DonableTestResource.kt +++ /dev/null @@ -1,8 +0,0 @@ -package theodolite.benchmark - - -import io.fabric8.kubernetes.client.CustomResourceDoneable -import io.fabric8.kubernetes.api.builder.Function - -class DonableTestResource(resource: TestResource, function: Function<TestResource,TestResource>) : - CustomResourceDoneable<TestResource>(resource, function) \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestResource.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestResource.kt deleted file mode 100644 index 2b2d82e83..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestResource.kt +++ /dev/null @@ -1,6 +0,0 @@ -package theodolite.benchmark - -import io.fabric8.kubernetes.client.CustomResource - -data class TestResource(var spec: TestSpec = TestSpec()): CustomResource() { -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestResourceList.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestResourceList.kt deleted file mode 100644 index 043c2fcf9..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestResourceList.kt +++ /dev/null @@ -1,5 +0,0 @@ -package theodolite.benchmark - -import io.fabric8.kubernetes.client.CustomResourceList - -class TestResourceList : CustomResourceList<TestResource> () \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestSpec.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestSpec.kt deleted file mode 100644 index a2475abd4..000000000 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/TestSpec.kt +++ /dev/null @@ -1,7 +0,0 @@ -package theodolite.benchmark - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize - -@JsonDeserialize -data class TestSpec(var message: String = "MEGAAIDS") { -} \ No newline at end of file diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteCRDExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteOperator.kt similarity index 55% rename from theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteCRDExecutor.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteOperator.kt index 5f79f6521..549b77230 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteCRDExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteOperator.kt @@ -1,14 +1,15 @@ package theodolite.execution -import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder import io.fabric8.kubernetes.client.DefaultKubernetesClient import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext import io.fabric8.kubernetes.client.informers.ResourceEventHandler import io.quarkus.runtime.annotations.QuarkusMain import mu.KotlinLogging import theodolite.benchmark.* -import theodolite.util.YamlParser -import kotlin.system.exitProcess +import io.fabric8.kubernetes.internal.KubernetesDeserializer + + + private var DEFAULT_NAMESPACE = "default" private val logger = KotlinLogging.logger {} @@ -24,15 +25,12 @@ object TheodoliteCRDExecutor { val client = DefaultKubernetesClient().inNamespace("default") -// val customResourceDefinition = CustomResourceDefinitionBuilder() -// .withNewMetadata().withName("benchmarkExecutions.demo.k8s.io").endMetadata() -// .withNewSpec() -// .withGroup("demo.k8s.io") -// .withVersion("v1alpha1") -// .withNewNames().withKind("BenchmarkExecution").withPlural("benchmarkExecutions").endNames() -// .withScope("Namespaced") -// .endSpec() -// .build() + KubernetesDeserializer.registerCustomKind( + "demo.k8s.io/v1alpha1", + "Benchmarkexecutions", + BenchmarkExecution::class.java + ) + val context = CustomResourceDefinitionContext.Builder() .withVersion("v1alpha1") @@ -44,21 +42,23 @@ object TheodoliteCRDExecutor { val informerFactory = client.informers() - val x = informerFactory.sharedIndexInformerForCustomResource(context, TestResource::class.java, - TestResourceList::class.java,10 * 60 * 1000.toLong()) + val x = informerFactory.sharedIndexInformerForCustomResource(context, BenchmarkExecution::class.java, + BenchmarkExecutionList::class.java,10 * 60 * 1000.toLong()) - x.addEventHandler(object : ResourceEventHandler<TestResource> { - override fun onAdd(webServer: TestResource) { - println("hello there") + x.addEventHandler(object : ResourceEventHandler<BenchmarkExecution> { + override fun onAdd(webServer: BenchmarkExecution) { + println("hello there add") + println(webServer.name) } - override fun onUpdate(webServer: TestResource, newWebServer: TestResource) { - println("hello there") + override fun onUpdate(webServer: BenchmarkExecution, newWebServer: BenchmarkExecution) { + println("hello there update") } - override fun onDelete(webServer: TestResource, b: Boolean) { + override fun onDelete(webServer: BenchmarkExecution, b: Boolean) { println("delted") + println(webServer.name) } }) @@ -66,7 +66,6 @@ object TheodoliteCRDExecutor { - //println(client.apiextensions().v1beta1().customResourceDefinitions().list()) //exitProcess(0) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt index fcf8244e8..4d290eab9 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/ConfigurationOverride.kt @@ -1,5 +1,8 @@ package theodolite.util +import com.fasterxml.jackson.databind.annotation.JsonDeserialize + +@JsonDeserialize class ConfigurationOverride { lateinit var patcher: PatcherDefinition lateinit var value: String diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt index 13b1e721c..fedcc0459 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt @@ -1,5 +1,8 @@ package theodolite.util +import com.fasterxml.jackson.databind.annotation.JsonDeserialize + +@JsonDeserialize class PatcherDefinition { lateinit var type: String lateinit var resource: String diff --git a/theodolite-quarkus/src/main/resources/yaml/testResource.yaml b/theodolite-quarkus/src/main/resources/yaml/resource.yaml similarity index 51% rename from theodolite-quarkus/src/main/resources/yaml/testResource.yaml rename to theodolite-quarkus/src/main/resources/yaml/resource.yaml index 81c3b2b96..15b45b191 100644 --- a/theodolite-quarkus/src/main/resources/yaml/testResource.yaml +++ b/theodolite-quarkus/src/main/resources/yaml/resource.yaml @@ -1,5 +1,6 @@ apiVersion: demo.k8s.io/v1alpha1 kind: Benchmarkexecutions metadata: - name: example-webserver -name: "Theodolite Test Context" \ No newline at end of file + name: aids-webserver +spec: + message: "Theodolite Test Context" \ No newline at end of file -- GitLab