From cb37c1ea735b348a0b5cdb8c1be162acfecdbeb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Henning?= <soeren.henning@email.uni-kiel.de> Date: Tue, 10 May 2022 19:34:38 +0200 Subject: [PATCH] Add docs on actions, fix #311 --- docs/creating-a-benchmark.md | 31 ++++++++++++++++-- docs/drafts/actions.md | 62 ------------------------------------ 2 files changed, 29 insertions(+), 64 deletions(-) delete mode 100644 docs/drafts/actions.md diff --git a/docs/creating-a-benchmark.md b/docs/creating-a-benchmark.md index b09c989e5..b4602d6f7 100644 --- a/docs/creating-a-benchmark.md +++ b/docs/creating-a-benchmark.md @@ -91,10 +91,37 @@ filesystem: - example-service.yaml ``` -<!-- ### Before and after actions --> +### Actions +Sometimes it is not sufficient to just define resources that are created and deleted when running a benchmark. Instead, it might be necessary to define certain actions that will be executed before running or after stopping the benchmark. +Theodolite allows to execute commands on running pods. This is similar to `kubectl exec` or Kubernetes' [container lifecycle handlers](https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/). Theodolite actions can run before (`beforeActions`) or after `afterActions` all `sut`, `loadGenerator` or `infrastructure` resources are deployed. +For example, the following actions will create a file in a pod with label `app: logger` before the SUT is started and delete if after the SUT is stopped: + ```yaml + sut: + resources: # ... + beforeActions: + - selector: + pod: + matchLabels: + app: logger + exec: + command: ["touch", "file-used-by-logger.txt"] + timeoutSeconds: 90 + afterActions: + - selector: + pod: + matchLabels: + app: logger + exec: + command: [ "rm", "file-used-by-logger.txt" ] + timeoutSeconds: 90 +``` + +Theodolite checks if all referenced pods are available for the specified actions. That means these pods must either be defined in `infrastructure` or already deployed in the cluster. If not all referenced pods are available, the benchmark will not be set as `Ready`. Consequently, an action cannot be executed on a pod that is defined as an SUT or load generator resource. + +*Note: Actions should be used sparingly. While it is possible to define entire benchmarks imperatively as actions, it is considered better practice to define as much as possible using declarative, native Kubernetes resource files.* <!-- A Benchmark refers to other Kubernetes resources (e.g., Deployments, Services, ConfigMaps), which describe the system under test, the load generator and infrastructure components such as a middleware used in the benchmark. To manage those resources, Theodolite needs to have access to them. This is done by bundling resources in ConfigMaps. @@ -116,7 +143,7 @@ If a benchmark is [executed by an Execution](running-benchmarks), these patchers ## Kafka Configuration Theodolite allows to automatically create and remove Kafka topics for each SLO experiment by setting a `kafkaConfig`. -It `bootstrapServer` needs to point your Kafka cluster and `topics` configures the list of Kafka topics to be created/removed. +`bootstrapServer` needs to point your Kafka cluster and `topics` configures the list of Kafka topics to be created/removed. For each topic, you configure its name, the number of partitions and the replication factor. With the `removeOnly: True` property, you can also instruct Theodolite to only remove topics and not create them. diff --git a/docs/drafts/actions.md b/docs/drafts/actions.md deleted file mode 100644 index 8092fddb0..000000000 --- a/docs/drafts/actions.md +++ /dev/null @@ -1,62 +0,0 @@ -## Infrastructure -The necessary infrastructure for an execution can be defined in the benchmark manifests. The related resources are create *before* an execution is started, and removed *after* an execution is finished. - -### Example - -```yaml - infrastructure: - resources: - - configMap: - name: "example-configmap" - files: - - "uc1-kstreams-deployment.yaml" -``` - -## Action Commands -Theodolite allows to execute commands on running pods (similar to the `kubectl exec -it <pod-name> -- <command>` command). This commands can be run either before (via so called `beforeActions`) or after (via so called `afterActions`) an experiment is executed. - -Theodolite checks if all required pods are available for the specified actions (i.e. the pods must either be defined as infrastructure or already deployed in the cluster). If not all pods/resources are available, the benchmark will not be set as `Ready`. Consequently, an action cannot be executed on a pod that is defined as an SUT or loadGen resource. - -### Example - -```yaml -# For the system under test - sut: - resources: ... - beforeActions: - - selector: - pod: - matchLabels: - app: busybox1 - exec: - command: ["touch", "test-file-sut"] - timeoutSeconds: 90 - afterActions: - - selector: - pod: - matchLabels: - app: busybox1 - exec: - command: [ "touch", "test-file-sut-after" ] - timeoutSeconds: 90 - -# analog, for the load generator - loadGenerator: - resources: ... - beforeActions: - - selector: - pod: - matchLabels: - app: busybox1 - exec: - command: ["touch", "test-file-loadGen"] - timeoutSeconds: 90 - afterActions: - - selector: - pod: - matchLabels: - app: busybox1 - exec: - command: [ "touch", "test-file-loadGen-after" ] - timeoutSeconds: 90 -``` \ No newline at end of file -- GitLab