Skip to content
Snippets Groups Projects
Commit cb37c1ea authored by Sören Henning's avatar Sören Henning
Browse files

Add docs on actions, fix #311

parent 08bde667
No related branches found
No related tags found
No related merge requests found
Pipeline #8236 passed
......@@ -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.
......
## 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment