Chaos engine
Bind an instance of a given app with one or more chaos experiments, define run characteristics, override chaos defaults, define steady-state hypothesis, reconciled by Litmus Chaos Operator.
This section describes the fields in the Chaos engine spec and the possible values that can be set against the same.
State Specifications
It is a user-defined flag to trigger chaos. Setting it to active ensures the successful execution of chaos. Patching it with stop aborts ongoing experiments. It has a corresponding flag in the chaos engine status field, called engineStatus which is updated by the controller based on the actual state of the chaos engine. You can tune it using the engineState field. It supports active and stop values.
Field | .spec.engineState |
---|---|
Description | Flag to control the state of the chaos engine |
Type | Mandatory |
Range | active , stop |
Default | active |
Notes | The engineState in the spec is a user defined flag to trigger chaos. Setting it to active ensures successful execution of chaos. Patching it with stop aborts ongoing experiments. It has a corresponding flag in the chaos engine status field, called engineStatus which is updated by the controller based on actual state of the chaos engine. |
Use the following example to tune this:
# contains the chaosengine state
# supports: active and stop states
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
# contains the state of engine
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: pod-delete-sa
experiments:
- name: pod-delete
Application Specifications
It contains AUT (application under test) details provided at spec.appinfo
inside chaosengine.
Field | .spec.appinfo.appns |
---|---|
Description | Flag to specify namespace of application under test |
Type | Optional |
Range | user-defined (type: string) |
Default | n/a |
Notes | The appns in the spec specifies the namespace of the AUT. Usually provided as a quoted string. It is optional for the infra chaos. |
Field | .spec.appinfo.applabel |
---|---|
Description | Flag to specify unique label of application under test |
Type | Optional |
Range | user-defined (type: string)(pattern: "label_key=label_value") |
Default | n/a |
Notes | The applabel in the spec specifies a unique label of the AUT. Usually provided as a quoted string of pattern key=value. Note that if multiple applications share the same label within a given namespace, the AUT is filtered based on the presence of the chaos annotation litmuschaos.io/chaos: "true" . If, however, the annotationCheck is disabled, then a random application (pod) sharing the specified label is selected for chaos. It is optional for the infra chaos. |
Field | .spec.appinfo.appkind |
---|---|
Description | Flag to specify resource kind of application under test |
Type | Optional |
Range | deployment , statefulset , daemonset , deploymentconfig , rollout |
Default | n/a (depends on app type) |
Notes | The appkind in the spec specifies the Kubernetes resource type of the app deployment. The Litmus ChaosOperator supports chaos on deployments, statefulsets and daemonsets. Application health check routines are dependent on the resource types, in case of some experiments. It is optional for the infra chaos |
Application Under Test
It defines the appns
, applabel
, and appkind
to set the namespace, labels, and kind of the application under test.
appkind
: It supportsdeployment
,statefulset
,daemonset
,deploymentconfig
, androllout
. It is mandatory for the pod-level experiments and optional for the rest of the experiments.
Use the following example to tune this:
# contains details of the AUT(application under test)
# appns: name of the application
# applabel: label of the applicaton
# appkind: kind of the application. supports: deployment, statefulset, daemonset, rollout, deploymentconfig
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
# AUT details
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: pod-delete-sa
experiments:
- name: pod-delete
RBAC Specifications
It specifies the name of the serviceaccount mapped to a role/clusterRole with enough permissions to execute the desired chaos experiment. The minimum permissions needed for any given experiment are provided in the .spec.definition.permissions field of the respective chaosexperiment CR. It can be tuned via chaosServiceAccount field.
Field | .spec.chaosServiceAccount |
---|---|
Description | Flag to specify serviceaccount used for chaos experiment |
Type | Mandatory |
Range | user-defined (type: string) |
Default | n/a |
Notes | The chaosServiceAccount in the spec specifies the name of the serviceaccount mapped to a role/clusterRole with enough permissions to execute the desired chaos experiment. The minimum permissions needed for any given experiment is provided in the .spec.definition.permissions field of the respective chaosexperiment CR. |
Use the following example to tune this:
# contains name of the serviceAccount which contains all the RBAC permissions required for the experiment
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
annotationCheck: "false"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
# name of the service account w/ sufficient permissions
chaosServiceAccount: pod-delete-sa
experiments:
- name: pod-delete
Runtime Specifications
It contains runtime details of the chaos experiments provided at .spec
inside chaosengine.
Field | .spec.terminationGracePeriodSeconds |
---|---|
Description | Flag to control terminationGracePeriodSeconds for the chaos pods(abort case) |
Type | Optional |
Range | integer value |
Default | 30 |
Notes | The terminationGracePeriodSeconds in the spec controls the terminationGracePeriodSeconds for the chaos resources in abort case. Chaos pods contains chaos revert upon abortion steps, which continuously looking for the termination signals. The terminationGracePeriodSeconds should be provided in such a way that the chaos pods got enough time for the revert before completely terminated. |
Field | .spec.jobCleanUpPolicy |
---|---|
Description | Flag to control cleanup of chaos experiment job post execution of chaos |
Type | Optional |
Range | delete , retain |
Default | delete |
Notes | The jobCleanUpPolicy controls whether the experiment pods are removed once execution completes. Set to retain for debug purposes (in the absence of standard logging mechanisms). |