-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
147 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Simulation hooks | ||
|
||
SimKube supports running arbitrary setup or cleanup scripts at a number of different points during the simulation | ||
process. The general method for configuring hooks is the same at each extension point: simply inject the following | ||
command into the Simulation custom resource: | ||
|
||
```yaml | ||
- cmd: echo # required | ||
args: ["foo"] # required | ||
ignoreFailure: true # optional, will not abort the simulation on failure | ||
sendSim: true # optional, will send the Simulation resource to the hook as JSON over stdin | ||
``` | ||
## Extension points | ||
There are four places where hooks can be injected: | ||
### preStartHooks | ||
Pre-start hooks run once before any other simulation setup; you can use these hooks to create additional namespaces, set | ||
up monitoring, etc. | ||
### postStopHooks | ||
Similarly, post-stop hooks run once after _all_ simulation iterations have completed and after all other cleanup tasks | ||
are complete. They can be used to clean up any resources or do additional reporting on the simulation results | ||
(extracting logs from relevant pods, for example). | ||
### preRunHooks | ||
Pre-run hooks run before _every_ iteration of the simulation, and can be used to re-create resources that should be | ||
"fresh" at the beginning of each iteration. They are the first thing the SimKube driver runs, before executing any | ||
other setup. | ||
### postRunHooks | ||
Lastly, post-run hooks run at the end of _every_ simulation iteration, and can be used to clean up resources that might | ||
pollute future simulation iterations. They are the last thing the SimKube driver runs. | ||
## Injecting hooks | ||
If you are using `skctl` to run your simulation, you can provide a set of hooks via a YAML file similar to the | ||
following, using the `--hooks` CLI argument: | ||
|
||
```yaml exec="on" result="yaml" | ||
cat examples/hooks/example.yml | ||
``` | ||
|
||
Otherwise, you can specify the hooks as part of the Simulation custom resource object. | ||
|
||
## Running hooks | ||
|
||
All executables needed to run hooks must be present and on the path in the `sk-ctrl` pod (for pre-start and post-stop | ||
hooks) or in the `sk-driver` pod (for pre-run and post-run hooks). The standard Docker images built for SimKube include | ||
`kubectl`, `curl`, and `jq` for this purpose. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Traces | ||
|
||
The SimKube tracer collects timeseries data about the events happening in a live Kubernetes cluster and exports that | ||
data to a trace file for future replay and analysis. These trace files can then be stored in a cloud provider or | ||
downloaded locally. We describe configuration options for each of these use cases. | ||
|
||
## Cloud storage | ||
|
||
We support exporting traces to Amazon S3, Google Cloud Storage, and Microsoft Azure Storage through the | ||
[object\_store](https://docs.rs/object_store/latest/object_store/) crate. The `sk-tracer` and `sk-driver` pods need to | ||
be configured with the correct permissions to write and read data to your chosen cloud storage. One option is to inject | ||
environment variables into the pod that object\_store understands. | ||
|
||
- Amazon S3: use the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables | ||
- Google Cloud Storage: use the `GOOGLE_SERVICE_ACCOUNT` environment variable and inject your service account JSON file | ||
into the `sk-tracer` pod | ||
- Microsoft Azure: use the `AZURE_STORAGE_ACCOUNT_NAME` and `AZURE_STORAGE_ACCOUNT_KEY` environment variables | ||
|
||
The object\_store crate will try other authentication/authorization methods if these environment variables are not set | ||
(for example, it will try to get credentials from the instance metadata endpoint for AWS), so these are not the only | ||
ways to grant permissions to the tracer and the driver. Configuring these permissions is beyond the scope of this | ||
documentation, and we encourage you to consult the IAM documentation for your chosen cloud provider(s). | ||
|
||
## Local storage | ||
|
||
If you do not have access to (or do not want to use) cloud storage, you can also save a trace file to local storage | ||
using, for example, `skctl export -o file:///path/to/trace`. However, using this trace file in the simulator is a bit | ||
more complicated; it will need to be injected into the node(s) where your Simulation driver pods will run, and then | ||
volume-mounted into the driver pod. If you are running locally via `kind`, you can add the following block to your | ||
`kind` config to mount the trace file directory on your laptop into the kind nodes: | ||
|
||
```yaml | ||
- role: worker | ||
extraMounts: | ||
- hostPath: /tmp/kind-node-data | ||
containerPath: /data | ||
``` | ||
From there, when you run a simulation, you need to specify the trace data using `skctl run --trace-path | ||
file:///data/trace`. This location is the location _inside the Kind node docker container_, not inside the driver pod. | ||
SimKube will automatically construct the appropriate volume mounts so that the driver pod can reference the trace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.