diff --git a/execution/infrastructure/kubernetes/rbac/role.yaml b/execution/infrastructure/kubernetes/rbac/role.yaml index 84ba14a8bc7a6eceb8a20596ede057ca2271b967..a21fd554f0f56b3955e9a9b6cf4bf95442b5d7af 100644 --- a/execution/infrastructure/kubernetes/rbac/role.yaml +++ b/execution/infrastructure/kubernetes/rbac/role.yaml @@ -38,4 +38,18 @@ rules: verbs: - delete - list - - create \ No newline at end of file + - create + - apiGroups: + - theodolite.com + resources: + - executions + - benchmarks + verbs: + - delete + - list + - get + - create + - watch + - update + - patch + diff --git a/theodolite-quarkus/config/BenchmarkType.yaml b/theodolite-quarkus/config/BenchmarkType.yaml index 60eb3bb9c31e3eab3e70f916b450372d56db4968..42b1cd08dc1949355c97edebc92ea7b5ab8799b2 100644 --- a/theodolite-quarkus/config/BenchmarkType.yaml +++ b/theodolite-quarkus/config/BenchmarkType.yaml @@ -20,7 +20,7 @@ loadTypes: container: "workload-generator" variableName: "NUM_SENSORS" kafkaConfig: - bootstrapServer: "theodolite-cp-kafka:9092" + bootstrapServer: "my-confluent-cp-kafka:9092" topics: - name: "input" numPartitions: 40 diff --git a/theodolite-quarkus/config/thedolite-operator.yaml b/theodolite-quarkus/config/thedolite-operator.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5059035b27cd9202e8e9b199f9ceb48d55c053d6 --- /dev/null +++ b/theodolite-quarkus/config/thedolite-operator.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: theodolite +spec: + selector: + matchLabels: + app: theodolite + replicas: 1 + template: + metadata: + labels: + app: theodolite + spec: + terminationGracePeriodSeconds: 0 + serviceAccountName: theodolite + containers: + - name: thedolite + image: lorenzboguhn/thedolite:latest + env: + - name: KUBECONFIG + value: "~/.kube/config" + - name: NAMESPACE + value: "default" \ No newline at end of file diff --git a/theodolite-quarkus/src/main/docker/Dockerfile.jvm b/theodolite-quarkus/src/main/docker/Dockerfile.jvm index 6733d5d441e8292e02547cf59131c706575e9d86..232ab03978c949e3d3b144813dd2c465d0d44a96 100644 --- a/theodolite-quarkus/src/main/docker/Dockerfile.jvm +++ b/theodolite-quarkus/src/main/docker/Dockerfile.jvm @@ -41,7 +41,7 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. -ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus.package.main-class=TheodoliteOperator" COPY build/lib/* /deployments/lib/ COPY build/*-runner.jar /deployments/app.jar COPY config/ /deployments/config/ diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt index dea845ec4c9209c603641a57112acf52815430a7..79b113936f95b64f7f53b2c7e1e9158204464719 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt @@ -20,17 +20,14 @@ class KubernetesBenchmark : Benchmark { lateinit var resourceTypes: List<TypeName> lateinit var loadTypes: List<TypeName> lateinit var kafkaConfig: KafkaConfig - lateinit var namespace: String - lateinit var path: String + val namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE + val path = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config" + val client = DefaultKubernetesClient().inNamespace(namespace) private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> { - //val path = "./../../../resources/main/yaml/" val parser = YamlParser() - namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE - logger.info { "Using $namespace as namespace." } - - val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace(namespace)) + val loader = K8sResourceLoader(client) return resources .map { resource -> val resourcePath = "$path/$resource" @@ -45,22 +42,32 @@ class KubernetesBenchmark : Benchmark { res: Resource, configurationOverrides: List<ConfigurationOverride?> ): BenchmarkDeployment { + logger.info { "Using $namespace as namespace." } + logger.info { "Using $path as resource path." } + val resources = loadKubernetesResources(this.appResource + this.loadGenResource) val patcherFactory = PatcherFactory() // patch the load dimension the resources - load.getType().forEach { patcherDefinition -> patcherFactory.createPatcher(patcherDefinition, resources).patch(load.get().toString()) } - res.getType().forEach{ patcherDefinition -> patcherFactory.createPatcher(patcherDefinition, resources).patch(res.get().toString()) } + load.getType().forEach { patcherDefinition -> + patcherFactory.createPatcher(patcherDefinition, resources).patch(load.get().toString()) + } + res.getType().forEach { patcherDefinition -> + patcherFactory.createPatcher(patcherDefinition, resources).patch(res.get().toString()) + } // Patch the given overrides - configurationOverrides.forEach { override -> override?.let { patcherFactory.createPatcher(it.patcher, resources).patch(override.value) } } - - + configurationOverrides.forEach { override -> + override?.let { + patcherFactory.createPatcher(it.patcher, resources).patch(override.value) + } + } return KubernetesBenchmarkDeployment( namespace = namespace, resources = resources.map { r -> r.second }, kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer), - topics = kafkaConfig.getKafkaTopics() + topics = kafkaConfig.getKafkaTopics(), + client = client ) } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt index 238cb17071c5b48fc883808b4334b79dada7ee32..8e4fce681147ffe7c80b37bab1d0dbb094b4036e 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt @@ -1,7 +1,7 @@ package theodolite.benchmark import io.fabric8.kubernetes.api.model.KubernetesResource -import io.fabric8.kubernetes.client.DefaultKubernetesClient +import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.quarkus.runtime.annotations.RegisterForReflection import org.apache.kafka.clients.admin.NewTopic import theodolite.k8s.K8sManager @@ -12,13 +12,12 @@ class KubernetesBenchmarkDeployment( val namespace: String, val resources: List<KubernetesResource>, private val kafkaConfig: HashMap<String, Any>, - private val topics: Collection<NewTopic> + private val topics: Collection<NewTopic>, + private val client: NamespacedKubernetesClient ) : BenchmarkDeployment { private val kafkaController = TopicManager(this.kafkaConfig) - private val kubernetesManager = K8sManager(DefaultKubernetesClient().inNamespace(namespace)) - + private val kubernetesManager = K8sManager(client) private val LABEL = "app.kubernetes.io/name=kafka-lag-exporter" - private val client = DefaultKubernetesClient().inNamespace(namespace) override fun setup() { kafkaController.createTopics(this.topics)