Chaos engineering

From j4flmao/agent-skills · View interactive version

Chaos engineering is an AI agent skill from the GitHub repository j4flmao/agent-skills. Use when the user asks about chaos engineering, chaos experiments, GameDays, Chaos Mesh, LitmusChaos, AWS Fault Injection Service, Azure Chaos Studio, steady-state hypotheses, or chaos in CI. Produces experiment designs, tool choice and a chaos program. Not for load testing (use quality-load-testing

How to use this skill

Skill file

Chaos Engineering

Purpose

Build confidence that the system withstands turbulent conditions by running controlled experiments: state a steady-state hypothesis, inject a realistic fault with a bounded blast radius, observe, and fix the weaknesses found. The goal is learning and hardening, not breaking things for show.

Agent Protocol

Trigger

"chaos engineering", "chaos experiment", "gameday", "chaos mesh", "litmus", "AWS FIS", "resilience testing", "chaos in CI", "steady state", "chaos program".

Input Context

Output Artifact

Experiment plan(s), tool manifests, GameDay runbook. No file unless requested.

Response Format

Hypothesis: When {fault}, {SLI} stays within {threshold}
Fault + tool: {e.g. pod-kill via Chaos Mesh PodChaos}
Blast radius: {env, % targets, duration}
Abort: {SLI condition / alarm}
Observations to record: {metrics, alerts fired, recovery time}
Follow-up: {tickets}

Completion Criteria

Principles (principlesofchaos.org)

  1. Define steady state as measurable output (orders/min, error ratio, p99), not internals.
  2. Hypothesize steady state continues in control and experiment groups.
  3. Inject real-world events (instance loss, latency, dependency errors, AZ outage, clock skew, full disks).
  4. Run in production when mature — staging first; minimize blast radius.
  5. Automate experiments to run continuously.

Maturity Path

| Stage | Activities |

|---|---|

| 1. Start | Tabletop exercises; manual pod/instance kills in staging during a GameDay |

| 2. Repeatable | Experiment catalog in Git; scheduled runs in staging; abort automation |

| 3. Production | Small-blast-radius prod experiments (one AZ, 1–5% of pods) with on-call aware |

| 4. Continuous | Experiments in CI/CD gates and scheduled prod runs; results feed SLO reviews |

Tool Selection

| Tool | Scope | Notes |

|---|---|---|

| Chaos Mesh (CNCF) | Kubernetes | CRDs: PodChaos, NetworkChaos, IOChaos, StressChaos, TimeChaos, DNSChaos, HTTPChaos; Workflows and Schedules |

| LitmusChaos (CNCF) | Kubernetes (+ some cloud faults) | ChaosHub experiment catalog; probes for steady-state checks |

| AWS Fault Injection Service | AWS resources (EC2, ECS, EKS, RDS, network, AZ power interruption scenarios) | Stop conditions via CloudWatch alarms; IAM-scoped |

| Azure Chaos Studio | Azure resources + agent-based VM faults | |

| Gremlin | Commercial, multi-platform | Hosted UI, safety controls |

| Toxiproxy | TCP proxy for tests | Great for integration tests in CI |

Experiment Example (Chaos Mesh)

apiVersion: chaos-mesh.org/v1alpha1
kind: PodChaos
metadata:
  name: checkout-pod-kill
  namespace: shop
spec:
  action: pod-kill
  mode: fixed-percent
  value: "20"
  selector:
    namespaces: [shop]
    labelSelectors:
      app: checkout
---
apiVersion: chaos-mesh.org/v1alpha1
kind: NetworkChaos
metadata:
  name: payments-latency
  namespace: shop
spec:
  action: delay
  mode: one
  selector:
    namespaces: [shop]
    labelSelectors:
      app: payments
  delay:
    latency: "500ms"
    correlation: "100"
    jitter: "50ms"
  duration: "5m"

Hypothesis for these: "With 20% of checkout pods killed and 500 ms extra latency on one payments pod, checkout success ratio stays ≥ 99.5% and p99 < 1.5 s." Typical findings: missing PDBs, retries without timeouts, single-replica dependencies, slow readiness.

AWS FIS Example (stop condition)

{
  "description": "Terminate 30% of checkout ECS tasks",
  "targets": {
    "tasks": {
      "resourceType": "aws:ecs:task",
      "resourceTags": { "service": "checkout" },
      "selectionMode": "PERCENT(30)"
    }
  },
  "actions": {
    "stopTasks": { "actionId": "aws:ecs:stop-task", "targets": { "Tasks": "tasks" } }
  },
  "stopConditions": [
    { "source": "aws:cloudwatch:alarm", "value": "arn:aws:cloudwatch:eu-west-1:123456789012:alarm:checkout-5xx-high" }
  ],
  "roleArn": "arn:aws:iam::123456789012:role/fis-experiments"
}

Chaos in CI/CD

#!/usr/bin/env bash
set -euo pipefail
kubectl apply -f chaos/payments-latency.yaml
trap 'kubectl delete -f chaos/payments-latency.yaml --ignore-not-found' EXIT

# Run a short load test and assert on SLIs instead of curl loops
k6 run --quiet tests/checkout-smoke.js   # thresholds in the script fail the job on SLO breach

Gate releases on resilience regressions in staging; keep prod experiments scheduled and announced.

GameDay Runbook

  1. Scope + hypothesis + abort criteria agreed; on-call and support notified; change freeze checked.
  2. Roles: facilitator, operator (injects), observers (dashboards), scribe.
  3. Baseline steady state for 10–15 minutes.
  4. Inject; observe alerts, dashboards, runbooks, human response.
  5. Abort if criteria met; otherwise end at planned time; verify recovery.
  6. Debrief within 48 h: what surprised us, detection gaps, action items with owners.

Anti-Patterns

Checklist

References

Merged Material

Content folded in from overlapping skills and notes.

Rules folded in: write the hypothesis and steady-state SLI before injecting; bound blast radius and duration; abort automatically on SLO breach; know the Linux mechanism (tc netem, cgroups, iptables) a tool uses so cleanup is verifiable.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.