From 67aca1498bb63203b14fae7fd0e4917cab9e7fe0 Mon Sep 17 00:00:00 2001
From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de>
Date: Mon, 22 Nov 2021 12:38:03 +0100
Subject: [PATCH] intrdocde infrastructure field in the benchmark crd

---
 docs/crd-benchmark-doc.md                     | 374 -----------------
 docs/{crd-execution-doc.md => crd-docu.md}    | 397 +++++++++++++++++-
 theodolite/crd/crd-benchmark.yaml             |   6 +
 .../examples/operator/example-benchmark.yaml  |   1 +
 .../examples/resources/test-service.yaml      |  16 +
 .../kotlin/theodolite/benchmark/Benchmark.kt  |   3 +
 .../benchmark/BenchmarkDeployment.kt          |   3 +-
 .../benchmark/KubernetesBenchmark.kt          |  21 +-
 .../execution/TheodoliteExecutor.kt           |   3 +
 .../test/kotlin/theodolite/TestBenchmark.kt   |   6 +
 .../execution/operator/BenchmarkCRDummy.kt    |   1 +
 .../k8s-resource-files/test-benchmark.yaml    |   1 +
 12 files changed, 435 insertions(+), 397 deletions(-)
 delete mode 100644 docs/crd-benchmark-doc.md
 rename docs/{crd-execution-doc.md => crd-docu.md} (51%)
 create mode 100644 theodolite/examples/resources/test-service.yaml

diff --git a/docs/crd-benchmark-doc.md b/docs/crd-benchmark-doc.md
deleted file mode 100644
index 1e12d6ebd..000000000
--- a/docs/crd-benchmark-doc.md
+++ /dev/null
@@ -1,374 +0,0 @@
-# API Reference
-
-Packages:
-
-- [theodolite.com/v1](#theodolitecomv1)
-
-# theodolite.com/v1
-
-Resource Types:
-
-- [benchmark](#benchmark)
-
-
-
-
-## benchmark
-<sup><sup>[↩ Parent](#theodolitecomv1 )</sup></sup>
-
-
-
-
-
-
-
-
-<table>
-    <thead>
-        <tr>
-            <th>Name</th>
-            <th>Type</th>
-            <th>Description</th>
-            <th>Required</th>
-        </tr>
-    </thead>
-    <tbody><tr>
-      <td><b>apiVersion</b></td>
-      <td>string</td>
-      <td>theodolite.com/v1</td>
-      <td>true</td>
-      </tr>
-      <tr>
-      <td><b>kind</b></td>
-      <td>string</td>
-      <td>benchmark</td>
-      <td>true</td>
-      </tr>
-      <tr>
-      <td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta">metadata</a></b></td>
-      <td>object</td>
-      <td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td>
-      <td>true</td>
-      </tr><tr>
-        <td><b><a href="#benchmarkspec">spec</a></b></td>
-        <td>object</td>
-        <td>
-          <br/>
-        </td>
-        <td>true</td>
-      </tr></tbody>
-</table>
-
-
-### benchmark.spec
-<sup><sup>[↩ Parent](#benchmark)</sup></sup>
-
-
-
-
-
-<table>
-    <thead>
-        <tr>
-            <th>Name</th>
-            <th>Type</th>
-            <th>Description</th>
-            <th>Required</th>
-        </tr>
-    </thead>
-    <tbody><tr>
-        <td><b>name</b></td>
-        <td>string</td>
-        <td>
-          This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten.<br/>
-        </td>
-        <td>false</td>
-      </tr><tr>
-        <td><b>appResource</b></td>
-        <td>[]string</td>
-        <td>
-          A list of file names that reference Kubernetes resources that are deployed on the cluster for the system under test (SUT).<br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b><a href="#benchmarkspeckafkaconfig">kafkaConfig</a></b></td>
-        <td>object</td>
-        <td>
-          Contains the Kafka configuration.<br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b>loadGenResource</b></td>
-        <td>[]string</td>
-        <td>
-          A list of file names that reference Kubernetes resources that are deployed on the cluster for the load generator.<br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b><a href="#benchmarkspecloadtypesindex">loadTypes</a></b></td>
-        <td>[]object</td>
-        <td>
-          A list of load types that can be scaled for this benchmark. For each load type the concrete values are defined in the execution object.<br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b><a href="#benchmarkspecresourcetypesindex">resourceTypes</a></b></td>
-        <td>[]object</td>
-        <td>
-          A list of resource types that can be scaled for this `benchmark` resource. For each resource type the concrete values are defined in the `execution` object.<br/>
-        </td>
-        <td>true</td>
-      </tr></tbody>
-</table>
-
-
-### benchmark.spec.kafkaConfig
-<sup><sup>[↩ Parent](#benchmarkspec)</sup></sup>
-
-
-
-Contains the Kafka configuration.
-
-<table>
-    <thead>
-        <tr>
-            <th>Name</th>
-            <th>Type</th>
-            <th>Description</th>
-            <th>Required</th>
-        </tr>
-    </thead>
-    <tbody><tr>
-        <td><b>bootstrapServer</b></td>
-        <td>string</td>
-        <td>
-          The bootstrap servers connection string.<br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b><a href="#benchmarkspeckafkaconfigtopicsindex">topics</a></b></td>
-        <td>[]object</td>
-        <td>
-          List of topics to be created for each experiment. Alternative theodolite offers the possibility to remove certain topics after each experiment.<br/>
-        </td>
-        <td>true</td>
-      </tr></tbody>
-</table>
-
-
-### benchmark.spec.kafkaConfig.topics[index]
-<sup><sup>[↩ Parent](#benchmarkspeckafkaconfig)</sup></sup>
-
-
-
-
-
-<table>
-    <thead>
-        <tr>
-            <th>Name</th>
-            <th>Type</th>
-            <th>Description</th>
-            <th>Required</th>
-        </tr>
-    </thead>
-    <tbody><tr>
-        <td><b>removeOnly</b></td>
-        <td>boolean</td>
-        <td>
-          Determines if this topic should only be deleted after each experiement. For removeOnly topics the name can be a RegEx describing the topic.<br/>
-          <br/>
-            <i>Default</i>: false<br/>
-        </td>
-        <td>false</td>
-      </tr><tr>
-        <td><b>name</b></td>
-        <td>string</td>
-        <td>
-          The name of the topic.<br/>
-          <br/>
-            <i>Default</i>: <br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b>numPartitions</b></td>
-        <td>integer</td>
-        <td>
-          The number of partitions of the topic.<br/>
-          <br/>
-            <i>Default</i>: 0<br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b>replicationFactor</b></td>
-        <td>integer</td>
-        <td>
-          The replication factor of the topic.<br/>
-          <br/>
-            <i>Default</i>: 0<br/>
-        </td>
-        <td>true</td>
-      </tr></tbody>
-</table>
-
-
-### benchmark.spec.loadTypes[index]
-<sup><sup>[↩ Parent](#benchmarkspec)</sup></sup>
-
-
-
-
-
-<table>
-    <thead>
-        <tr>
-            <th>Name</th>
-            <th>Type</th>
-            <th>Description</th>
-            <th>Required</th>
-        </tr>
-    </thead>
-    <tbody><tr>
-        <td><b><a href="#benchmarkspecloadtypesindexpatchersindex">patchers</a></b></td>
-        <td>[]object</td>
-        <td>
-          List of patchers used to scale this resource type.<br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b>typeName</b></td>
-        <td>string</td>
-        <td>
-          Name of the load type.<br/>
-        </td>
-        <td>true</td>
-      </tr></tbody>
-</table>
-
-
-### benchmark.spec.loadTypes[index].patchers[index]
-<sup><sup>[↩ Parent](#benchmarkspecloadtypesindex)</sup></sup>
-
-
-
-
-
-<table>
-    <thead>
-        <tr>
-            <th>Name</th>
-            <th>Type</th>
-            <th>Description</th>
-            <th>Required</th>
-        </tr>
-    </thead>
-    <tbody><tr>
-        <td><b>properties</b></td>
-        <td>object</td>
-        <td>
-          (Optional) Patcher specific additional arguments.<br/>
-          <br/>
-            <i>Default</i>: map[]<br/>
-        </td>
-        <td>false</td>
-      </tr><tr>
-        <td><b>resource</b></td>
-        <td>string</td>
-        <td>
-          Specifies the Kubernetes resource to be patched.<br/>
-          <br/>
-            <i>Default</i>: <br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b>type</b></td>
-        <td>string</td>
-        <td>
-          Type of the Patcher.<br/>
-          <br/>
-            <i>Default</i>: <br/>
-        </td>
-        <td>true</td>
-      </tr></tbody>
-</table>
-
-
-### benchmark.spec.resourceTypes[index]
-<sup><sup>[↩ Parent](#benchmarkspec)</sup></sup>
-
-
-
-
-
-<table>
-    <thead>
-        <tr>
-            <th>Name</th>
-            <th>Type</th>
-            <th>Description</th>
-            <th>Required</th>
-        </tr>
-    </thead>
-    <tbody><tr>
-        <td><b><a href="#benchmarkspecresourcetypesindexpatchersindex">patchers</a></b></td>
-        <td>[]object</td>
-        <td>
-          List of patchers used to scale this resource type.<br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b>typeName</b></td>
-        <td>string</td>
-        <td>
-          Name of the resource type.<br/>
-        </td>
-        <td>true</td>
-      </tr></tbody>
-</table>
-
-
-### benchmark.spec.resourceTypes[index].patchers[index]
-<sup><sup>[↩ Parent](#benchmarkspecresourcetypesindex)</sup></sup>
-
-
-
-
-
-<table>
-    <thead>
-        <tr>
-            <th>Name</th>
-            <th>Type</th>
-            <th>Description</th>
-            <th>Required</th>
-        </tr>
-    </thead>
-    <tbody><tr>
-        <td><b>properties</b></td>
-        <td>object</td>
-        <td>
-          (Optional) Patcher specific additional arguments.<br/>
-          <br/>
-            <i>Default</i>: map[]<br/>
-        </td>
-        <td>false</td>
-      </tr><tr>
-        <td><b>resource</b></td>
-        <td>string</td>
-        <td>
-          Specifies the Kubernetes resource to be patched.<br/>
-          <br/>
-            <i>Default</i>: <br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b>type</b></td>
-        <td>string</td>
-        <td>
-          Type of the patcher.<br/>
-          <br/>
-            <i>Default</i>: <br/>
-        </td>
-        <td>true</td>
-      </tr></tbody>
-</table>
\ No newline at end of file
diff --git a/docs/crd-execution-doc.md b/docs/crd-docu.md
similarity index 51%
rename from docs/crd-execution-doc.md
rename to docs/crd-docu.md
index 21b5cdeca..f3397bdff 100644
--- a/docs/crd-execution-doc.md
+++ b/docs/crd-docu.md
@@ -8,11 +8,380 @@ Packages:
 
 Resource Types:
 
+- [benchmark](#benchmark)
+
 - [execution](#execution)
 
 
 
 
+## benchmark
+<sup><sup>[↩ Parent](#theodolitecomv1 )</sup></sup>
+
+
+
+
+
+
+
+
+<table>
+    <thead>
+        <tr>
+            <th>Name</th>
+            <th>Type</th>
+            <th>Description</th>
+            <th>Required</th>
+        </tr>
+    </thead>
+    <tbody><tr>
+      <td><b>apiVersion</b></td>
+      <td>string</td>
+      <td>theodolite.com/v1</td>
+      <td>true</td>
+      </tr>
+      <tr>
+      <td><b>kind</b></td>
+      <td>string</td>
+      <td>benchmark</td>
+      <td>true</td>
+      </tr>
+      <tr>
+      <td><b><a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectmeta-v1-meta">metadata</a></b></td>
+      <td>object</td>
+      <td>Refer to the Kubernetes API documentation for the fields of the `metadata` field.</td>
+      <td>true</td>
+      </tr><tr>
+        <td><b><a href="#benchmarkspec">spec</a></b></td>
+        <td>object</td>
+        <td>
+          <br/>
+        </td>
+        <td>true</td>
+      </tr></tbody>
+</table>
+
+
+### benchmark.spec
+<sup><sup>[↩ Parent](#benchmark)</sup></sup>
+
+
+
+
+
+<table>
+    <thead>
+        <tr>
+            <th>Name</th>
+            <th>Type</th>
+            <th>Description</th>
+            <th>Required</th>
+        </tr>
+    </thead>
+    <tbody><tr>
+        <td><b>infrastructure</b></td>
+        <td>[]string</td>
+        <td>
+          A list of file names that reference Kubernetes resources that are deployed on the cluster to create the required infrastructure.<br/>
+        </td>
+        <td>false</td>
+      </tr><tr>
+        <td><b>name</b></td>
+        <td>string</td>
+        <td>
+          This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten.<br/>
+        </td>
+        <td>false</td>
+      </tr><tr>
+        <td><b>appResource</b></td>
+        <td>[]string</td>
+        <td>
+          A list of file names that reference Kubernetes resources that are deployed on the cluster for the system under test (SUT).<br/>
+        </td>
+        <td>true</td>
+      </tr><tr>
+        <td><b><a href="#benchmarkspeckafkaconfig">kafkaConfig</a></b></td>
+        <td>object</td>
+        <td>
+          Contains the Kafka configuration.<br/>
+        </td>
+        <td>true</td>
+      </tr><tr>
+        <td><b>loadGenResource</b></td>
+        <td>[]string</td>
+        <td>
+          A list of file names that reference Kubernetes resources that are deployed on the cluster for the load generator.<br/>
+        </td>
+        <td>true</td>
+      </tr><tr>
+        <td><b><a href="#benchmarkspecloadtypesindex">loadTypes</a></b></td>
+        <td>[]object</td>
+        <td>
+          A list of load types that can be scaled for this benchmark. For each load type the concrete values are defined in the execution object.<br/>
+        </td>
+        <td>true</td>
+      </tr><tr>
+        <td><b><a href="#benchmarkspecresourcetypesindex">resourceTypes</a></b></td>
+        <td>[]object</td>
+        <td>
+          A list of resource types that can be scaled for this `benchmark` resource. For each resource type the concrete values are defined in the `execution` object.<br/>
+        </td>
+        <td>true</td>
+      </tr></tbody>
+</table>
+
+
+### benchmark.spec.kafkaConfig
+<sup><sup>[↩ Parent](#benchmarkspec)</sup></sup>
+
+
+
+Contains the Kafka configuration.
+
+<table>
+    <thead>
+        <tr>
+            <th>Name</th>
+            <th>Type</th>
+            <th>Description</th>
+            <th>Required</th>
+        </tr>
+    </thead>
+    <tbody><tr>
+        <td><b>bootstrapServer</b></td>
+        <td>string</td>
+        <td>
+          The bootstrap servers connection string.<br/>
+        </td>
+        <td>true</td>
+      </tr><tr>
+        <td><b><a href="#benchmarkspeckafkaconfigtopicsindex">topics</a></b></td>
+        <td>[]object</td>
+        <td>
+          List of topics to be created for each experiment. Alternative theodolite offers the possibility to remove certain topics after each experiment.<br/>
+        </td>
+        <td>true</td>
+      </tr></tbody>
+</table>
+
+
+### benchmark.spec.kafkaConfig.topics[index]
+<sup><sup>[↩ Parent](#benchmarkspeckafkaconfig)</sup></sup>
+
+
+
+
+
+<table>
+    <thead>
+        <tr>
+            <th>Name</th>
+            <th>Type</th>
+            <th>Description</th>
+            <th>Required</th>
+        </tr>
+    </thead>
+    <tbody><tr>
+        <td><b>numPartitions</b></td>
+        <td>integer</td>
+        <td>
+          The number of partitions of the topic.<br/>
+          <br/>
+            <i>Default</i>: 0<br/>
+        </td>
+        <td>false</td>
+      </tr><tr>
+        <td><b>removeOnly</b></td>
+        <td>boolean</td>
+        <td>
+          Determines if this topic should only be deleted after each experiement. For removeOnly topics the name can be a RegEx describing the topic.<br/>
+          <br/>
+            <i>Default</i>: false<br/>
+        </td>
+        <td>false</td>
+      </tr><tr>
+        <td><b>replicationFactor</b></td>
+        <td>integer</td>
+        <td>
+          The replication factor of the topic.<br/>
+          <br/>
+            <i>Default</i>: 0<br/>
+        </td>
+        <td>false</td>
+      </tr><tr>
+        <td><b>name</b></td>
+        <td>string</td>
+        <td>
+          The name of the topic.<br/>
+          <br/>
+            <i>Default</i>: <br/>
+        </td>
+        <td>true</td>
+      </tr></tbody>
+</table>
+
+
+### benchmark.spec.loadTypes[index]
+<sup><sup>[↩ Parent](#benchmarkspec)</sup></sup>
+
+
+
+
+
+<table>
+    <thead>
+        <tr>
+            <th>Name</th>
+            <th>Type</th>
+            <th>Description</th>
+            <th>Required</th>
+        </tr>
+    </thead>
+    <tbody><tr>
+        <td><b><a href="#benchmarkspecloadtypesindexpatchersindex">patchers</a></b></td>
+        <td>[]object</td>
+        <td>
+          List of patchers used to scale this resource type.<br/>
+        </td>
+        <td>true</td>
+      </tr><tr>
+        <td><b>typeName</b></td>
+        <td>string</td>
+        <td>
+          Name of the load type.<br/>
+        </td>
+        <td>true</td>
+      </tr></tbody>
+</table>
+
+
+### benchmark.spec.loadTypes[index].patchers[index]
+<sup><sup>[↩ Parent](#benchmarkspecloadtypesindex)</sup></sup>
+
+
+
+
+
+<table>
+    <thead>
+        <tr>
+            <th>Name</th>
+            <th>Type</th>
+            <th>Description</th>
+            <th>Required</th>
+        </tr>
+    </thead>
+    <tbody><tr>
+        <td><b>properties</b></td>
+        <td>map[string]string</td>
+        <td>
+          (Optional) Patcher specific additional arguments.<br/>
+          <br/>
+            <i>Default</i>: map[]<br/>
+        </td>
+        <td>false</td>
+      </tr><tr>
+        <td><b>resource</b></td>
+        <td>string</td>
+        <td>
+          Specifies the Kubernetes resource to be patched.<br/>
+          <br/>
+            <i>Default</i>: <br/>
+        </td>
+        <td>true</td>
+      </tr><tr>
+        <td><b>type</b></td>
+        <td>string</td>
+        <td>
+          Type of the Patcher.<br/>
+          <br/>
+            <i>Default</i>: <br/>
+        </td>
+        <td>true</td>
+      </tr></tbody>
+</table>
+
+
+### benchmark.spec.resourceTypes[index]
+<sup><sup>[↩ Parent](#benchmarkspec)</sup></sup>
+
+
+
+
+
+<table>
+    <thead>
+        <tr>
+            <th>Name</th>
+            <th>Type</th>
+            <th>Description</th>
+            <th>Required</th>
+        </tr>
+    </thead>
+    <tbody><tr>
+        <td><b><a href="#benchmarkspecresourcetypesindexpatchersindex">patchers</a></b></td>
+        <td>[]object</td>
+        <td>
+          List of patchers used to scale this resource type.<br/>
+        </td>
+        <td>true</td>
+      </tr><tr>
+        <td><b>typeName</b></td>
+        <td>string</td>
+        <td>
+          Name of the resource type.<br/>
+        </td>
+        <td>true</td>
+      </tr></tbody>
+</table>
+
+
+### benchmark.spec.resourceTypes[index].patchers[index]
+<sup><sup>[↩ Parent](#benchmarkspecresourcetypesindex)</sup></sup>
+
+
+
+
+
+<table>
+    <thead>
+        <tr>
+            <th>Name</th>
+            <th>Type</th>
+            <th>Description</th>
+            <th>Required</th>
+        </tr>
+    </thead>
+    <tbody><tr>
+        <td><b>properties</b></td>
+        <td>map[string]string</td>
+        <td>
+          (Optional) Patcher specific additional arguments.<br/>
+          <br/>
+            <i>Default</i>: map[]<br/>
+        </td>
+        <td>false</td>
+      </tr><tr>
+        <td><b>resource</b></td>
+        <td>string</td>
+        <td>
+          Specifies the Kubernetes resource to be patched.<br/>
+          <br/>
+            <i>Default</i>: <br/>
+        </td>
+        <td>true</td>
+      </tr><tr>
+        <td><b>type</b></td>
+        <td>string</td>
+        <td>
+          Type of the patcher.<br/>
+          <br/>
+            <i>Default</i>: <br/>
+        </td>
+        <td>true</td>
+      </tr></tbody>
+</table>
+
 ## execution
 <sup><sup>[↩ Parent](#theodolitecomv1 )</sup></sup>
 
@@ -224,7 +593,7 @@ Patcher used to patch a resource
     </thead>
     <tbody><tr>
         <td><b>properties</b></td>
-        <td>object</td>
+        <td>map[string]string</td>
         <td>
           (Optional) Patcher specific additional arguments.<br/>
           <br/>
@@ -369,7 +738,7 @@ Specifies the scaling resource that is benchmarked.
         <td><b>resourceValues</b></td>
         <td>[]integer</td>
         <td>
-          <br/>
+          List of resource values for the specified resource type.<br/>
         </td>
         <td>true</td>
       </tr></tbody>
@@ -393,12 +762,14 @@ Specifies the scaling resource that is benchmarked.
         </tr>
     </thead>
     <tbody><tr>
-        <td><b>externalSloUrl</b></td>
-        <td>string</td>
+        <td><b>properties</b></td>
+        <td>map[string]string</td>
         <td>
-          Connection string for a external slo analysis.<br/>
+          (Optional) SLO specific additional arguments.<br/>
+          <br/>
+            <i>Default</i>: map[]<br/>
         </td>
-        <td>true</td>
+        <td>false</td>
       </tr><tr>
         <td><b>offset</b></td>
         <td>integer</td>
@@ -420,19 +791,5 @@ Specifies the scaling resource that is benchmarked.
           The type of the SLO. It must match 'lag trend'.<br/>
         </td>
         <td>true</td>
-      </tr><tr>
-        <td><b>threshold</b></td>
-        <td>integer</td>
-        <td>
-          The threshold the SUT should meet for a sucessful experiment.<br/>
-        </td>
-        <td>true</td>
-      </tr><tr>
-        <td><b>warmup</b></td>
-        <td>integer</td>
-        <td>
-          Seconds of time that are ignored in the analysis.<br/>
-        </td>
-        <td>true</td>
       </tr></tbody>
 </table>
\ No newline at end of file
diff --git a/theodolite/crd/crd-benchmark.yaml b/theodolite/crd/crd-benchmark.yaml
index 7a861276a..165f7a081 100644
--- a/theodolite/crd/crd-benchmark.yaml
+++ b/theodolite/crd/crd-benchmark.yaml
@@ -25,6 +25,12 @@ spec:
               name:
                 description: This field exists only for technical reasons and should not be set by the user. The value of the field will be overwritten.
                 type: string
+              infrastructure:
+                description: A list of file names that reference Kubernetes resources that are deployed on the cluster to create the required infrastructure.
+                type: array
+                minItems: 1
+                items:
+                  type: string
               appResource:
                 description: A list of file names that reference Kubernetes resources that are deployed on the cluster for the system under test (SUT).
                 type: array
diff --git a/theodolite/examples/operator/example-benchmark.yaml b/theodolite/examples/operator/example-benchmark.yaml
index 0950b2bdc..e3f3a31bf 100644
--- a/theodolite/examples/operator/example-benchmark.yaml
+++ b/theodolite/examples/operator/example-benchmark.yaml
@@ -3,6 +3,7 @@ kind: benchmark
 metadata:
   name: uc1-kstreams
 spec:
+  infrastructure: []
   appResource:
     - "uc1-kstreams-deployment.yaml"
   loadGenResource:
diff --git a/theodolite/examples/resources/test-service.yaml b/theodolite/examples/resources/test-service.yaml
new file mode 100644
index 000000000..2b502810b
--- /dev/null
+++ b/theodolite/examples/resources/test-service.yaml
@@ -0,0 +1,16 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: test-service
+  labels:
+    app: test-service
+spec:
+  type: ClusterIP
+  clusterIP: None
+  selector:
+    app: test
+  ports:
+    - name: coordination
+      port: 5701
+      targetPort: 5701
+      protocol: TCP
diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt
index 05d021b1b..cf2fac733 100644
--- a/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt
+++ b/theodolite/src/main/kotlin/theodolite/benchmark/Benchmark.kt
@@ -14,6 +14,9 @@ import theodolite.util.Resource
 @RegisterForReflection
 interface Benchmark {
 
+    fun setupInfrastructure()
+    fun teardownInfrastructure()
+
     /**
      * Builds a Deployment that can be deployed.
      * @return a BenchmarkDeployment.
diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkDeployment.kt b/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkDeployment.kt
index 92d3f7a01..fd01ecd98 100644
--- a/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkDeployment.kt
+++ b/theodolite/src/main/kotlin/theodolite/benchmark/BenchmarkDeployment.kt
@@ -7,8 +7,7 @@ package theodolite.benchmark
 interface BenchmarkDeployment {
 
     /**
-     * Setup a benchmark. This method is responsible for deploying the resources
-     * and organize the needed infrastructure.
+     * Setup a benchmark. This method is responsible for deploying the resources of a benchmark.
      */
     fun setup()
 
diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
index b9a2fc7f1..20bbcc11d 100644
--- a/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
+++ b/theodolite/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
@@ -3,8 +3,10 @@ package theodolite.benchmark
 import com.fasterxml.jackson.databind.annotation.JsonDeserialize
 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 mu.KotlinLogging
+import theodolite.k8s.K8sManager
 import theodolite.k8s.K8sResourceLoader
 import theodolite.patcher.PatcherFactory
 import theodolite.util.*
@@ -36,11 +38,14 @@ class KubernetesBenchmark : KubernetesResource, Benchmark {
     lateinit var name: String
     lateinit var appResource: List<String>
     lateinit var loadGenResource: List<String>
+    lateinit var infrastructure: List<String>
     lateinit var resourceTypes: List<TypeName>
     lateinit var loadTypes: List<TypeName>
     lateinit var kafkaConfig: KafkaConfig
     var namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
 
+    @Transient
+    private val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace)
 
     /**
      * Loads [KubernetesResource]s.
@@ -62,6 +67,20 @@ class KubernetesBenchmark : KubernetesResource, Benchmark {
             }
     }
 
+    override fun setupInfrastructure() {
+        val kubernetesManager = K8sManager(this.client)
+        loadKubernetesResources(this.infrastructure)
+            .map{it.second}
+            .forEach { kubernetesManager.deploy(it) }
+    }
+
+    override fun teardownInfrastructure() {
+        val kubernetesManager = K8sManager(this.client)
+        loadKubernetesResources(this.infrastructure)
+            .map{it.second}
+            .forEach { kubernetesManager.remove(it) }
+        }
+
     /**
      * Builds a deployment.
      * First loads all required resources and then patches them to the concrete load and resources for the experiment.
@@ -106,7 +125,7 @@ class KubernetesBenchmark : KubernetesResource, Benchmark {
             afterTeardownDelay = afterTeardownDelay,
             kafkaConfig = hashMapOf("bootstrap.servers" to kafkaConfig.bootstrapServer),
             topics = kafkaConfig.topics,
-            client = DefaultKubernetesClient().inNamespace(namespace)
+            client = this.client
         )
     }
 }
diff --git a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt
index a5a4904f8..315d1cf1a 100644
--- a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt
+++ b/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt
@@ -113,6 +113,8 @@ class TheodoliteExecutor(
      * execution and benchmark objects.
      */
     fun run() {
+        kubernetesBenchmark.setupInfrastructure()
+
         val ioHandler = IOHandler()
         val resultsFolder = ioHandler.getResultFolderURL()
         this.config.executionId = getAndIncrementExecutionID(resultsFolder + "expID.txt")
@@ -136,6 +138,7 @@ class TheodoliteExecutor(
                 "${resultsFolder}exp${this.config.executionId}-result"
             )
         }
+        kubernetesBenchmark.teardownInfrastructure()
     }
 
     private fun getAndIncrementExecutionID(fileURL: String): Int {
diff --git a/theodolite/src/test/kotlin/theodolite/TestBenchmark.kt b/theodolite/src/test/kotlin/theodolite/TestBenchmark.kt
index 913a27a1b..b08c1a18a 100644
--- a/theodolite/src/test/kotlin/theodolite/TestBenchmark.kt
+++ b/theodolite/src/test/kotlin/theodolite/TestBenchmark.kt
@@ -8,6 +8,12 @@ import theodolite.util.Resource
 
 class TestBenchmark : Benchmark {
 
+    override fun setupInfrastructure() {
+    }
+
+    override fun teardownInfrastructure() {
+    }
+
     override fun buildDeployment(
         load: LoadDimension,
         res: Resource,
diff --git a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt b/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt
index f3fd06a16..63e6e0740 100644
--- a/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt
+++ b/theodolite/src/test/kotlin/theodolite/execution/operator/BenchmarkCRDummy.kt
@@ -24,6 +24,7 @@ class BenchmarkCRDummy(name: String) {
         benchmarkCR.kind = "Benchmark"
         benchmarkCR.apiVersion = "v1"
 
+        benchmark.infrastructure = emptyList()
         benchmark.appResource = emptyList()
         benchmark.loadGenResource = emptyList()
         benchmark.resourceTypes = emptyList()
diff --git a/theodolite/src/test/resources/k8s-resource-files/test-benchmark.yaml b/theodolite/src/test/resources/k8s-resource-files/test-benchmark.yaml
index e690aa56d..8cd4be5fa 100644
--- a/theodolite/src/test/resources/k8s-resource-files/test-benchmark.yaml
+++ b/theodolite/src/test/resources/k8s-resource-files/test-benchmark.yaml
@@ -3,6 +3,7 @@ kind: benchmark
 metadata:
   name: example-benchmark
 spec:
+  infrastructure: []
   appResource:
     - "uc1-kstreams-deployment.yaml"
     - "aggregation-service.yaml"
-- 
GitLab