LitmusChaos Setup
Installing LitmusChaos and Running Chaos Monkey Experiments¶
LitmusChaos requires dedicated namespaces for running experiments and its own components. Follow these steps to set up the environment:
-
Create a namespace for chaos experiments:
-
Set namespace context for subsequent commands:
-
Create the 'litmuschaos' service account (prerequisite for RB, install LitmusChaos components):
Note: The
litmusnamespace is where LitmusChaos controller and related components are installed, whilechaos-testingis used for experiment workloads. -
Grant permissions (RBAC):
Ensure thelitmuschaosservice account has access to thechaos-testingnamespace. Apply a role binding with restricted permissions:
(Adjust the role and service account based on your cluster configuration. For production, use a more restrictive role thankubectl create rolebinding chaos-runner-binding \ --namespace=chaos-testing \ --role=chaos-runner \ --serviceaccount=litmus:litmuschaoscluster-admin.) -
Install LitmusChaos via Helm:
Add the LitmusChaos Helm repository and deploy:
Alternatively, use Kubernetes manifests from the LitmusChaos GitHub repo for installation.helm repo add litmuschaos https://charts.litmuschaos.io helm install litmuschaos litmuschaos/litmuschaos --namespace litmus -
Run a Chaos Monkey experiment:
Create a Chaos Monkey experiment manifest (e.g.,pod-delete.yaml):
This example deletes a pod with labelapiVersion: litmuschaos.io/v1alpha1 kind: ChaosEngine metadata: name: pod-delete namespace: chaos-testing spec: engineName: chaos-mono appInfo: appNS: chaos-testing appLabels: {} appPods: [] chaosServiceAccount: litmuschaos experiments: - name: pod-delete spec: engineName: chaos-mono workloadKind: pod workloadSelector: matchLabels: app: nginx chaosNamespace: chaos-testing metadata: annotations: "chaos.io/timeout": "30s" spec: signal: true signalType: pod podDelete: gracePeriod: 5 preKill: true postKill: trueapp: nginxin thechaos-testingnamespace. Adjust labels and parameters based on your workload. -
Execute and verify the experiment:
Check logs and metrics to confirm the chaos effect and recovery.
Apply the manifest and monitor the results: