Skip to content

Commit 4c29346

Browse files
authored
Docs: Added a doc for using the gitlab CI component to run CTK as part of gitlab pipelines (#167)
Signed-off-by: Chris Doyle <[email protected]>
1 parent 832f63c commit 4c29346

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ nav:
156156
- Action: deployment/gcp/cloudrunjob.md
157157
- GitHub:
158158
- Action: deployment/github.md
159+
- GitLab:
160+
- Component: deployment/gitlab.md
159161
- Kubernetes:
160162
- Operator: deployment/k8s/operator.md
161163
- Develop:

sources/deployment/gitlab.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Run Chaos Toolkit with Gitlab Component
2+
3+
Chaos Toolkit provides a ready to run component for Gitlab that makes it easy
4+
to run experiments on Gitlab CICD.
5+
6+
## Overview
7+
8+
The component can be found at on the [Gitlab CI/CD Catalog][ghmp].
9+
10+
[ghmp]: https://gitlab.com/explore/catalog/cdoyle27/chaostoolkit-ci-component
11+
12+
The way it works is a follows:
13+
14+
* Create a sub-directory in the repository, with your experiments.
15+
* Add the component using an `include` block to a Gilab CI file and select a strategy to trigger it.
16+
Whether it's on a push event, manually triggered or scheduled
17+
18+
Here is an example of a simple workflow:
19+
20+
```yaml
21+
include:
22+
- component: gitlab.com/cdoyle27/chaostoolkit-ci-component/[email protected]
23+
inputs:
24+
experiment-file: "experiment.yaml"
25+
```
26+
27+
The component has a set of arguments allowing you to tune the environment
28+
used to run the experiment. Let's see a few them below.
29+
30+
## Configure the Component
31+
32+
### Change the Python version
33+
34+
By default, the component runs using Python 3.11. You can change this by
35+
setting `python-version` to another version.
36+
37+
### Enable higher verbosity
38+
39+
The component runs with the normal verbosity level of the Chaos Toolkit by
40+
default. You can adjust this to make it more verbose by setting
41+
`verbose: "true"`.
42+
43+
### Set the working directory
44+
45+
It is a good practice to run the experiment from a specific directory in
46+
the repository. To do so you simply set the `working-dir` argument to
47+
whichever path matches your structure. The component will move into that
48+
directory upon running the experiment.
49+
50+
### Set the experiment file path
51+
52+
By default the component will look for an experiment file named `experiment.json`
53+
in the working directory. You will likely give it a different name, for instance
54+
because all your experiments are part of the same directory. Set this name
55+
with the `experiment-file` argument.
56+
57+
### Manage dependencies
58+
59+
The component offers two inclusive approaches to manage the Chaos Toolkit
60+
dependencies.
61+
62+
### Automated dependencies management
63+
64+
As a matter of convenience, the component provides the `install-dependencies`
65+
argument allowing you to select a set of well-known extensions to be installed.
66+
67+
* `aws`
68+
* `gcp`
69+
* `k8s`
70+
* `otel`
71+
* `slack`
72+
73+
So if your experiment targets Google Cloud and relies on Slack and Open
74+
Telemetry, you can set `install-dependencies: gcp;slack;otel`.
75+
76+
### Extra dependencies management
77+
78+
Your experiment will often require more dependencies to be installed. You can
79+
do so by adding a `requirements.txt` file into the working directory and set
80+
the `dependencies-file`. For instance: `dependencies-file: requirements.txt`.
81+
82+
The file must follow the [requirements][rq] format but its name can be anything.
83+
84+
[rq]: https://pip.pypa.io/en/stable/reference/requirements-file-format/
85+
86+
### Enable local binaries
87+
88+
Experiments often rely on binaries found in the `PATH` to be present. You
89+
can do so by adding these binaries in a `bin` directory either at the top
90+
of the repository or inside the working directory. Both locations will be
91+
automatically added to the `PATH` and therefore available to the experiment.
92+
93+
For instance, when running against AWS EKS, this is where you would put the
94+
[aws-iam-authenticator][awsiamauth] binary.
95+
96+
[awsiamauth]: https://github.com/kubernetes-sigs/aws-iam-authenticator
97+
98+
### Passing environment variables & secrets
99+
100+
The component performs as expected when it comes to environment variables. You
101+
simply declare them on the job and they are available to the experiment. This works by setting the job
102+
name or using the jobs default name `chaostoolkit` if no job name is provided. This allows users to
103+
overide or set variables.
104+
105+
Same goes for secrets. For instance:
106+
107+
108+
```yaml
109+
include:
110+
- component: gitlab.com/cdoyle27/chaostoolkit-ci-component/[email protected]
111+
inputs:
112+
experiment-file: "experiment.yaml"
113+
working-dir: "example_experiment"
114+
dependencies-file: "requirements.txt"
115+
116+
chaostoolkit:
117+
variables:
118+
new_file_name: "../README_ENV_MOVED.md"
119+
```
120+
121+
### Upload execution results
122+
123+
The component will upload the results of the Chaos Toolkit execution
124+
as part of the job artifacts. The uploaded files are the `chaostoolkit.log`
125+
and `journal.json` files. Both files are aggregated into a compressed
126+
archive. You can set the name of that archive with the `result-artifact-name`
127+
argument.

0 commit comments

Comments
 (0)