Skip to content

Commit 4a5f015

Browse files
fix/docs: add litmusctl-syntax.md file with comprehensive documentation
Signed-off-by: suntiwari3495-arch <[email protected]>
1 parent 21cb5d0 commit 4a5f015

File tree

1 file changed

+364
-0
lines changed

1 file changed

+364
-0
lines changed
Lines changed: 364 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,364 @@
1+
# Litmusctl Syntax
2+
3+
## Overview
4+
5+
`litmusctl` is a command-line tool for managing LitmusChaos infrastructure plane. It follows a structured syntax pattern that makes it intuitive to use for various chaos engineering operations.
6+
7+
## Basic Syntax
8+
9+
```bash
10+
litmusctl [command] [TYPE] [flags]
11+
```
12+
13+
### Components
14+
15+
- **Command**: Specifies the operation you want to perform (e.g., `connect`, `create`, `get`, `config`, `disconnect`, `run`, `update`)
16+
- **Type**: Refers to the resource type you're operating on (e.g., `chaos-infra`, `project`, `chaos-experiment`, `chaos-environment`)
17+
- **Flags**: Additional parameters that provide specific information for the operation (e.g., `--project-id`, `--non-interactive`, `--config`)
18+
19+
## Available Commands
20+
21+
### 1. `config` - Configuration Management
22+
23+
Manage litmusctl accounts and configuration settings.
24+
25+
#### Subcommands
26+
27+
**Set Account**
28+
```bash
29+
litmusctl config set-account
30+
```
31+
Configure a new ChaosCenter account with endpoint, username, and password.
32+
33+
**Use Account**
34+
```bash
35+
litmusctl config use-account --endpoint="<endpoint-url>" --username="<username>"
36+
```
37+
Switch between multiple configured accounts.
38+
39+
**Get Accounts**
40+
```bash
41+
litmusctl config get-accounts
42+
```
43+
List all configured accounts in `.litmusconfig`.
44+
45+
**View Configuration**
46+
```bash
47+
litmusctl config view
48+
```
49+
Display current `.litmusconfig` settings.
50+
51+
---
52+
53+
### 2. `connect` - Connect Resources
54+
55+
Establish connections to chaos resources.
56+
57+
**Connect Chaos Infrastructure**
58+
```bash
59+
litmusctl connect chaos-infra
60+
```
61+
62+
**Flags:**
63+
- `--project-id`: Specify the project ID
64+
- `--environment-id`: Specify the environment ID
65+
- `--non-interactive`: Enable non-interactive mode (all required information must be provided via flags)
66+
- `--installation-mode`: Installation mode (`cluster` or `namespace`)
67+
- `--chaos-infra-name`: Name for the chaos infrastructure
68+
- `--chaos-infra-description`: Description for the chaos infrastructure
69+
- `--platform-name`: Platform name (AWS, GKE, Openshift, Rancher, Others)
70+
- `--namespace`: Kubernetes namespace for installation
71+
- `--service-account`: Service account name
72+
- `--skip-ssl`: Skip SSL/TLS verification (true/false)
73+
- `--node-selector`: Node selector for deployments
74+
75+
**Example (Non-interactive mode):**
76+
```bash
77+
litmusctl connect chaos-infra \
78+
--project-id="<project-id>" \
79+
--environment-id="<environment-id>" \
80+
--chaos-infra-name="my-chaos-infra" \
81+
--installation-mode="cluster" \
82+
--non-interactive
83+
```
84+
85+
---
86+
87+
### 3. `disconnect` - Disconnect Resources
88+
89+
Disconnect chaos resources from ChaosCenter.
90+
91+
**Disconnect Chaos Infrastructure**
92+
```bash
93+
litmusctl disconnect chaos-infra <chaos-infra-id> --project-id="<project-id>"
94+
```
95+
96+
**Example:**
97+
```bash
98+
litmusctl disconnect chaos-infra 13dsf3d1-5324-54af-4g23-5331g5v2364f --project-id="50addd40-8767-448c-a91a-5071543a2d8e"
99+
```
100+
101+
---
102+
103+
### 4. `create` - Create Resources
104+
105+
Create new projects, experiments, and environments.
106+
107+
**Create Project**
108+
```bash
109+
litmusctl create project --name="<project-name>"
110+
```
111+
112+
**Create Chaos Environment**
113+
```bash
114+
litmusctl create chaos-environment
115+
```
116+
You will be prompted for:
117+
- Project ID
118+
- Environment Name
119+
- Environment Type (Production/Non-Production)
120+
121+
**Create Chaos Experiment**
122+
```bash
123+
litmusctl create chaos-experiment -f <experiment-manifest.yml> --project-id="<project-id>" --chaos-infra-id="<chaos-infra-id>"
124+
```
125+
126+
**Flags:**
127+
- `-f`: Path to experiment manifest file
128+
- `--project-id`: Target project ID
129+
- `--chaos-infra-id`: Target chaos infrastructure ID
130+
131+
**Example:**
132+
```bash
133+
litmusctl create chaos-experiment \
134+
-f custom-chaos-experiment.yml \
135+
--project-id="eb7fc0a0-5878-4454-a9db-b67d283713bc" \
136+
--chaos-infra-id="e7eb0386-085c-49c2-b550-8d85b58fd"
137+
```
138+
139+
---
140+
141+
### 5. `get` - Retrieve Information
142+
143+
Query and list various resources.
144+
145+
**Get Projects**
146+
```bash
147+
litmusctl get projects
148+
```
149+
Lists all projects accessible to the user with their IDs, names, and creation timestamps.
150+
151+
**Get Chaos Infrastructures**
152+
```bash
153+
litmusctl get chaos-infra
154+
```
155+
You will be prompted for the Project ID. Returns infrastructure ID, name, and status.
156+
157+
**Get Chaos Environments**
158+
```bash
159+
litmusctl get chaos-environment
160+
```
161+
Lists chaos environments with their IDs, names, types, and timestamps.
162+
163+
**Get Chaos Experiments**
164+
```bash
165+
litmusctl get chaos-experiments
166+
```
167+
Lists chaos experiments within a project.
168+
169+
---
170+
171+
### 6. `run` - Execute Operations
172+
173+
Execute chaos experiments and other operations.
174+
175+
**Run Chaos Experiment**
176+
```bash
177+
litmusctl run chaos-experiment
178+
```
179+
You will be prompted for:
180+
- Project ID
181+
- Chaos Experiment ID
182+
183+
**Example:**
184+
```bash
185+
litmusctl run chaos-experiment
186+
# Enter the Project ID: eb7fc0a0-5878-4454-a9db-b67d283713bc
187+
# Enter the Chaos Experiment ID: test_exp
188+
```
189+
190+
---
191+
192+
### 7. `update` - Update Resources
193+
194+
Modify existing resources and settings.
195+
196+
**Update Password**
197+
```bash
198+
litmusctl update password
199+
```
200+
Change the password for your ChaosCenter account. You will be prompted for:
201+
- Username
202+
- Old Password
203+
- New Password
204+
- Confirm Password
205+
206+
---
207+
208+
### 8. `version` - Version Information
209+
210+
**Check Version**
211+
```bash
212+
litmusctl version
213+
```
214+
Display the current version of litmusctl.
215+
216+
---
217+
218+
## Global Flags
219+
220+
These flags can be used with most commands:
221+
222+
- `--config`: Specify a custom config file path (default: `${HOME}/.litmusconfig`)
223+
- `--help` or `-h`: Display help information for any command
224+
225+
---
226+
227+
## Interactive vs Non-Interactive Mode
228+
229+
### Interactive Mode
230+
By default, litmusctl operates in interactive mode where it prompts you for required information.
231+
232+
```bash
233+
litmusctl connect chaos-infra
234+
# Will prompt for all required details
235+
```
236+
237+
### Non-Interactive Mode
238+
Use the `--non-interactive` flag along with all required flags to run commands without prompts.
239+
240+
```bash
241+
litmusctl connect chaos-infra \
242+
--project-id="<project-id>" \
243+
--environment-id="<environment-id>" \
244+
--chaos-infra-name="my-infra" \
245+
--non-interactive
246+
```
247+
248+
**Note:** Only `litmusctl connect chaos-infra` requires the `--non-interactive` flag. Other commands automatically use non-interactive mode when all required flags are provided.
249+
250+
---
251+
252+
## Configuration File
253+
254+
litmusctl uses the `.litmusconfig` file to manage multiple accounts:
255+
256+
- **Default Location:** `${HOME}/.litmusconfig`
257+
- **Custom Location:** Use `--config` flag to specify a different location
258+
- **No Merging:** If `--config` is specified, only that file is loaded (no merging with default config)
259+
260+
---
261+
262+
## Common Workflows
263+
264+
### Initial Setup
265+
```bash
266+
# 1. Configure your account
267+
litmusctl config set-account
268+
269+
# 2. View configured accounts
270+
litmusctl config get-accounts
271+
272+
# 3. Create or select a project
273+
litmusctl create project --name="my-project"
274+
litmusctl get projects
275+
```
276+
277+
### Connecting Infrastructure
278+
```bash
279+
# 1. Create an environment (if needed)
280+
litmusctl create chaos-environment
281+
282+
# 2. Connect chaos infrastructure
283+
litmusctl connect chaos-infra
284+
285+
# 3. Verify connection
286+
litmusctl get chaos-infra
287+
```
288+
289+
### Running Experiments
290+
```bash
291+
# 1. Create experiment
292+
litmusctl create chaos-experiment -f experiment.yml --project-id="<id>" --chaos-infra-id="<id>"
293+
294+
# 2. Run experiment
295+
litmusctl run chaos-experiment
296+
297+
# 3. List experiments
298+
litmusctl get chaos-experiments
299+
```
300+
301+
---
302+
303+
## Examples
304+
305+
### Example 1: Complete Setup in Non-Interactive Mode
306+
```bash
307+
# Set account
308+
litmusctl config set-account \
309+
--endpoint="https://chaos.example.com" \
310+
--username="admin" \
311+
--password="password"
312+
313+
# Create project
314+
litmusctl create project --name="production-chaos"
315+
316+
# Get project ID
317+
litmusctl get projects
318+
319+
# Connect infrastructure
320+
litmusctl connect chaos-infra \
321+
--project-id="50addd40-8767-448c-a91a-5071543a2d8e" \
322+
--environment-id="prod-env" \
323+
--chaos-infra-name="prod-cluster-1" \
324+
--installation-mode="cluster" \
325+
--platform-name="GKE" \
326+
--namespace="litmus" \
327+
--non-interactive
328+
```
329+
330+
### Example 2: Interactive Workflow
331+
```bash
332+
# Configure account interactively
333+
litmusctl config set-account
334+
# Follow prompts for endpoint, username, password
335+
336+
# Connect infrastructure interactively
337+
litmusctl connect chaos-infra
338+
# Follow prompts for all required details
339+
340+
# Create and run experiment interactively
341+
litmusctl create chaos-experiment -f my-experiment.yml
342+
# Follow prompts for project-id and chaos-infra-id
343+
344+
litmusctl run chaos-experiment
345+
# Follow prompts for project-id and experiment-id
346+
```
347+
348+
---
349+
350+
## Tips and Best Practices
351+
352+
1. **Use Descriptive Names:** Give meaningful names to your infrastructure and experiments for easier management
353+
2. **Leverage Non-Interactive Mode:** Use non-interactive mode in CI/CD pipelines and automation scripts
354+
3. **Version Compatibility:** Always check compatibility between litmusctl version and ChaosCenter version
355+
4. **Multiple Accounts:** Use `config get-accounts` and `config use-account` to manage multiple ChaosCenter environments
356+
5. **Namespace Mode vs Cluster Mode:** Choose installation mode based on your RBAC requirements and blast radius preferences
357+
358+
---
359+
360+
## Additional Resources
361+
362+
- For detailed usage examples, refer to the [litmusctl usage documentation](https://github.com/litmuschaos/litmusctl/blob/master/Usage_0.23.0.md)
363+
- For installation instructions, see the [litmusctl installation guide](https://docs.litmuschaos.io/docs/litmusctl/installation)
364+
- For prerequisites and requirements, check the [litmusctl README](https://github.com/litmuschaos/litmusctl/blob/master/README.md)

0 commit comments

Comments
 (0)