Skip to content

litmuschaos/litmus-python

Repository files navigation

litmus-python:

Slack Channel GitHub Workflow Docker Pulls GitHub issues Twitter Follow CII Best Practices YouTube Channel

  • This repo consists of Litmus Chaos Experiments written in python. The examples in this repo are good indicators of how to construct the experiments in python: complete with steady state checks, chaosresult generation, chaos injection, post chaos checks, create events and reports for observability and configure sinks for these.

NOTE

  • This repo can be viewed as an extension to the litmuschaos/litmus repo. The litmus repo will also continue to be the project's community-facing meta repo housing other important project artifacts. In that sense, litmus-py is very similar to and therefore a sister repo of litmus-go which houses examples for experiment business logic written in go.

Litmus SDK

The Litmus SDK provides a simple way to bootstrap your experiment and helps create the aforementioned artifacts in the appropriate directory (i.e., as per the chaos-category) based on an attributes file provided as input by the chart-developer. The scaffolded files consist of placeholders which can then be filled as desired.

It generates the custom chaos experiments with some default Pre & Post Chaos Checks (AUT & Auxiliary Applications status checks). It can use the existing chaoslib (present inside /chaoslib directory), if available else It will create a new chaoslib inside the corresponding directory.

Refer Litmus-SDK for more details

Overview

Litmus-Python chaos experiments are fundamental units within the LitmusChaos architecture. Users can choose between readily available chaos experiments or create new ones to construct a required Chaos Workflow.

To know more about LitmusChaos experiments refer to this.

Experiment Flow :

  • Experiment business logic image has to be updated in spec.definition.image along with experiment entrypoint and tunable parameters in ChaosEngine (CR) which holds experiment-specific chaos parameters. ChaosExperiment is created by chaos runner which is managed by chaos operator Refer litmus-python pod-delete experiment
  • Chaos Engine holds experiment-specific parameters. This CR is also updated/patched with the status of the chaos experiments, making it the single source of truth concerning the chaos.
  • Now we need to fit Experiment and Engine into the workflow, Chaos Workflow is a set of different operations coupled together to achieve desired chaos impact on a Kubernetes Cluster. LitmusChaos leverages the popular workflow & GitOps tool, Argo, to achieve this.
    • Add experiment manifest in install-experiment artifacts and engine in run-chaos artifacts.
    • Follow the steps in pod-delete workflow or User guide
  • Now fork and clone chaos-charts, Enter into workflow directory.
    • Enter into charts directory to add charts which has been generated using sdk, for reference
    • Enter into workflow directory and add workflow manifests for reference
    • Connect your Git repository with chaos-center ChaosHub
  • Workflow can be added as a predefined workflow in Github and users can test by following the given steps:
    • Fork and clone chaos-charts, now Enter into workflow directory.
    • Follow the same structure for your workflow and push it. For example
    • Connect your Git repository with chaos-center ChaosHub
  • Schedule your workflow with chaos-center in given manner, by selecting your connected ChaosHub
  • It can be scheduled for repeated execution.

How to get started?

Refer the LitmusChaos documentation litmus docs

How do I contribute?

You can contribute by raising issues, improving the documentation, contributing to the core framework and tooling, etc.

Head over to the Contribution guide

Blogs

License

FOSSA Status