-
Notifications
You must be signed in to change notification settings - Fork 118
Docs: Add comprehensive litmusctl syntax and usage documentation #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
suntiwari3495-arch
wants to merge
4
commits into
litmuschaos:master
Choose a base branch
from
suntiwari3495-arch:litmusctlSyntax
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+355
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4a5f015
fix/docs: add litmusctl-syntax.md file with comprehensive documentation
suntiwari3495-arch 7055d87
fix line ending
suntiwari3495-arch 29f20e8
Remove tips section and update resource links address the review from…
suntiwari3495-arch c2c5348
add the file path in sidebar.js
suntiwari3495-arch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,354 @@ | ||
| # Litmusctl Syntax | ||
|
|
||
| ## Overview | ||
|
|
||
| `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. | ||
|
|
||
| ## Basic Syntax | ||
|
|
||
| ```bash | ||
| litmusctl [command] [TYPE] [flags] | ||
| ``` | ||
|
|
||
| ### Components | ||
|
|
||
| - **Command**: Specifies the operation you want to perform (e.g., `connect`, `create`, `get`, `config`, `disconnect`, `run`, `update`) | ||
| - **Type**: Refers to the resource type you're operating on (e.g., `chaos-infra`, `project`, `chaos-experiment`, `chaos-environment`) | ||
| - **Flags**: Additional parameters that provide specific information for the operation (e.g., `--project-id`, `--non-interactive`, `--config`) | ||
|
|
||
| ## Available Commands | ||
|
|
||
| ### 1. `config` - Configuration Management | ||
|
|
||
| Manage litmusctl accounts and configuration settings. | ||
|
|
||
| #### Subcommands | ||
|
|
||
| **Set Account** | ||
| ```bash | ||
| litmusctl config set-account | ||
| ``` | ||
| Configure a new ChaosCenter account with endpoint, username, and password. | ||
|
|
||
| **Use Account** | ||
| ```bash | ||
| litmusctl config use-account --endpoint="<endpoint-url>" --username="<username>" | ||
| ``` | ||
| Switch between multiple configured accounts. | ||
|
|
||
| **Get Accounts** | ||
| ```bash | ||
| litmusctl config get-accounts | ||
| ``` | ||
| List all configured accounts in `.litmusconfig`. | ||
|
|
||
| **View Configuration** | ||
| ```bash | ||
| litmusctl config view | ||
| ``` | ||
| Display current `.litmusconfig` settings. | ||
|
|
||
| --- | ||
|
|
||
| ### 2. `connect` - Connect Resources | ||
|
|
||
| Establish connections to chaos resources. | ||
|
|
||
| **Connect Chaos Infrastructure** | ||
| ```bash | ||
| litmusctl connect chaos-infra | ||
| ``` | ||
|
|
||
| **Flags:** | ||
| - `--project-id`: Specify the project ID | ||
| - `--environment-id`: Specify the environment ID | ||
| - `--non-interactive`: Enable non-interactive mode (all required information must be provided via flags) | ||
| - `--installation-mode`: Installation mode (`cluster` or `namespace`) | ||
| - `--chaos-infra-name`: Name for the chaos infrastructure | ||
| - `--chaos-infra-description`: Description for the chaos infrastructure | ||
| - `--platform-name`: Platform name (AWS, GKE, Openshift, Rancher, Others) | ||
| - `--namespace`: Kubernetes namespace for installation | ||
| - `--service-account`: Service account name | ||
| - `--skip-ssl`: Skip SSL/TLS verification (true/false) | ||
| - `--node-selector`: Node selector for deployments | ||
|
|
||
| **Example (Non-interactive mode):** | ||
| ```bash | ||
| litmusctl connect chaos-infra \ | ||
| --project-id="<project-id>" \ | ||
| --environment-id="<environment-id>" \ | ||
| --chaos-infra-name="my-chaos-infra" \ | ||
| --installation-mode="cluster" \ | ||
| --non-interactive | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 3. `disconnect` - Disconnect Resources | ||
|
|
||
| Disconnect chaos resources from ChaosCenter. | ||
|
|
||
| **Disconnect Chaos Infrastructure** | ||
| ```bash | ||
| litmusctl disconnect chaos-infra <chaos-infra-id> --project-id="<project-id>" | ||
| ``` | ||
|
|
||
| **Example:** | ||
| ```bash | ||
| litmusctl disconnect chaos-infra 13dsf3d1-5324-54af-4g23-5331g5v2364f --project-id="50addd40-8767-448c-a91a-5071543a2d8e" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 4. `create` - Create Resources | ||
|
|
||
| Create new projects, experiments, and environments. | ||
|
|
||
| **Create Project** | ||
| ```bash | ||
| litmusctl create project --name="<project-name>" | ||
| ``` | ||
|
|
||
| **Create Chaos Environment** | ||
| ```bash | ||
| litmusctl create chaos-environment | ||
| ``` | ||
| You will be prompted for: | ||
| - Project ID | ||
| - Environment Name | ||
| - Environment Type (Production/Non-Production) | ||
|
|
||
| **Create Chaos Experiment** | ||
| ```bash | ||
| litmusctl create chaos-experiment -f <experiment-manifest.yml> --project-id="<project-id>" --chaos-infra-id="<chaos-infra-id>" | ||
| ``` | ||
|
|
||
| **Flags:** | ||
| - `-f`: Path to experiment manifest file | ||
| - `--project-id`: Target project ID | ||
| - `--chaos-infra-id`: Target chaos infrastructure ID | ||
|
|
||
| **Example:** | ||
| ```bash | ||
| litmusctl create chaos-experiment \ | ||
| -f custom-chaos-experiment.yml \ | ||
| --project-id="eb7fc0a0-5878-4454-a9db-b67d283713bc" \ | ||
| --chaos-infra-id="e7eb0386-085c-49c2-b550-8d85b58fd" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 5. `get` - Retrieve Information | ||
|
|
||
| Query and list various resources. | ||
|
|
||
| **Get Projects** | ||
| ```bash | ||
| litmusctl get projects | ||
| ``` | ||
| Lists all projects accessible to the user with their IDs, names, and creation timestamps. | ||
|
|
||
| **Get Chaos Infrastructures** | ||
| ```bash | ||
| litmusctl get chaos-infra | ||
| ``` | ||
| You will be prompted for the Project ID. Returns infrastructure ID, name, and status. | ||
|
|
||
| **Get Chaos Environments** | ||
| ```bash | ||
| litmusctl get chaos-environment | ||
| ``` | ||
| Lists chaos environments with their IDs, names, types, and timestamps. | ||
|
|
||
| **Get Chaos Experiments** | ||
| ```bash | ||
| litmusctl get chaos-experiments | ||
| ``` | ||
| Lists chaos experiments within a project. | ||
|
|
||
| --- | ||
|
|
||
| ### 6. `run` - Execute Operations | ||
|
|
||
| Execute chaos experiments and other operations. | ||
|
|
||
| **Run Chaos Experiment** | ||
| ```bash | ||
| litmusctl run chaos-experiment | ||
| ``` | ||
| You will be prompted for: | ||
| - Project ID | ||
| - Chaos Experiment ID | ||
|
|
||
| **Example:** | ||
| ```bash | ||
| litmusctl run chaos-experiment | ||
| # Enter the Project ID: eb7fc0a0-5878-4454-a9db-b67d283713bc | ||
| # Enter the Chaos Experiment ID: test_exp | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 7. `update` - Update Resources | ||
|
|
||
| Modify existing resources and settings. | ||
|
|
||
| **Update Password** | ||
| ```bash | ||
| litmusctl update password | ||
| ``` | ||
| Change the password for your ChaosCenter account. You will be prompted for: | ||
| - Username | ||
| - Old Password | ||
| - New Password | ||
| - Confirm Password | ||
|
|
||
| --- | ||
|
|
||
| ### 8. `version` - Version Information | ||
|
|
||
| **Check Version** | ||
| ```bash | ||
| litmusctl version | ||
| ``` | ||
| Display the current version of litmusctl. | ||
|
|
||
| --- | ||
|
|
||
| ## Global Flags | ||
|
|
||
| These flags can be used with most commands: | ||
|
|
||
| - `--config`: Specify a custom config file path (default: `${HOME}/.litmusconfig`) | ||
| - `--help` or `-h`: Display help information for any command | ||
|
|
||
| --- | ||
|
|
||
| ## Interactive vs Non-Interactive Mode | ||
|
|
||
| ### Interactive Mode | ||
| By default, litmusctl operates in interactive mode where it prompts you for required information. | ||
|
|
||
| ```bash | ||
| litmusctl connect chaos-infra | ||
| # Will prompt for all required details | ||
| ``` | ||
|
|
||
| ### Non-Interactive Mode | ||
| Use the `--non-interactive` flag along with all required flags to run commands without prompts. | ||
|
|
||
| ```bash | ||
| litmusctl connect chaos-infra \ | ||
| --project-id="<project-id>" \ | ||
| --environment-id="<environment-id>" \ | ||
| --chaos-infra-name="my-infra" \ | ||
| --non-interactive | ||
| ``` | ||
|
|
||
| **Note:** Only `litmusctl connect chaos-infra` requires the `--non-interactive` flag. Other commands automatically use non-interactive mode when all required flags are provided. | ||
|
|
||
| --- | ||
|
|
||
| ## Configuration File | ||
|
|
||
| litmusctl uses the `.litmusconfig` file to manage multiple accounts: | ||
|
|
||
| - **Default Location:** `${HOME}/.litmusconfig` | ||
| - **Custom Location:** Use `--config` flag to specify a different location | ||
| - **No Merging:** If `--config` is specified, only that file is loaded (no merging with default config) | ||
|
|
||
| --- | ||
|
|
||
| ## Common Workflows | ||
|
|
||
| ### Initial Setup | ||
| ```bash | ||
| # 1. Configure your account | ||
| litmusctl config set-account | ||
|
|
||
| # 2. View configured accounts | ||
| litmusctl config get-accounts | ||
|
|
||
| # 3. Create or select a project | ||
| litmusctl create project --name="my-project" | ||
| litmusctl get projects | ||
| ``` | ||
|
|
||
| ### Connecting Infrastructure | ||
| ```bash | ||
| # 1. Create an environment (if needed) | ||
| litmusctl create chaos-environment | ||
|
|
||
| # 2. Connect chaos infrastructure | ||
| litmusctl connect chaos-infra | ||
|
|
||
| # 3. Verify connection | ||
| litmusctl get chaos-infra | ||
| ``` | ||
|
|
||
| ### Running Experiments | ||
| ```bash | ||
| # 1. Create experiment | ||
| litmusctl create chaos-experiment -f experiment.yml --project-id="<id>" --chaos-infra-id="<id>" | ||
|
|
||
| # 2. Run experiment | ||
| litmusctl run chaos-experiment | ||
|
|
||
| # 3. List experiments | ||
| litmusctl get chaos-experiments | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1: Complete Setup in Non-Interactive Mode | ||
| ```bash | ||
| # Set account | ||
| litmusctl config set-account \ | ||
| --endpoint="https://chaos.example.com" \ | ||
| --username="admin" \ | ||
| --password="password" | ||
|
|
||
| # Create project | ||
| litmusctl create project --name="production-chaos" | ||
|
|
||
| # Get project ID | ||
| litmusctl get projects | ||
|
|
||
| # Connect infrastructure | ||
| litmusctl connect chaos-infra \ | ||
| --project-id="50addd40-8767-448c-a91a-5071543a2d8e" \ | ||
| --environment-id="prod-env" \ | ||
| --chaos-infra-name="prod-cluster-1" \ | ||
| --installation-mode="cluster" \ | ||
| --platform-name="GKE" \ | ||
| --namespace="litmus" \ | ||
| --non-interactive | ||
| ``` | ||
|
|
||
| ### Example 2: Interactive Workflow | ||
| ```bash | ||
| # Configure account interactively | ||
| litmusctl config set-account | ||
| # Follow prompts for endpoint, username, password | ||
|
|
||
| # Connect infrastructure interactively | ||
| litmusctl connect chaos-infra | ||
| # Follow prompts for all required details | ||
|
|
||
| # Create and run experiment interactively | ||
| litmusctl create chaos-experiment -f my-experiment.yml | ||
| # Follow prompts for project-id and chaos-infra-id | ||
|
|
||
| litmusctl run chaos-experiment | ||
| # Follow prompts for project-id and experiment-id | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| - For detailed usage examples, refer to the [litmusctl usage documentation](/docs/next/litmusctl/litmusctl-usage) | ||
| - For installation instructions, see the [litmusctl installation guide](/docs/next/litmusctl/installation) | ||
| - [Contribute to litmusctl](https://github.com/litmuschaos/litmusctl) | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.