一键导入
chaos-engineering
Design and run chaos experiments in Kubernetes — pod failures, network partitions, resource pressure with LitmusChaos and manual chaos.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Design and run chaos experiments in Kubernetes — pod failures, network partitions, resource pressure with LitmusChaos and manual chaos.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Production-grade GitHub Actions workflows — reusable workflows, OIDC cloud auth, caching, matrix builds, and environment protection rules. Use when the user creates, reviews, or debugs CI/CD pipelines in .github/workflows, or asks about GitHub Actions deployment, OIDC authentication, or workflow optimization.
Systematic diagnosis of Kubernetes pod failures — CrashLoopBackOff, OOMKilled, Pending, ImagePullBackOff, and service connectivity issues. Use when the user encounters pods not starting, container restart loops, scheduling failures, or service unreachability in a K8s cluster.
Implement distributed tracing with OpenTelemetry, Tempo/Jaeger — instrumentation, sampling, and trace-to-log correlation. Use when the user asks about distributed tracing, OpenTelemetry setup, span instrumentation, trace propagation, or connecting traces to logs and metrics.
Design reusable React components with compound patterns, controlled/uncontrolled hybrids, typed prop APIs, async state handling, and ARIA accessibility. Use when the user creates, refactors, or reviews React components, or mentions props, hooks, .tsx files, component APIs, or accessible UI patterns.
Apply STRIDE threat modeling to system designs, identify IDOR and authorization vulnerabilities, and build threat matrices for security reviews. Use when the user designs a new system, reviews an architecture, prepares for a security audit, or asks about common API vulnerabilities like IDOR or broken access control.
Secure CI/CD pipelines with keyless signing, OIDC federation, provenance attestations, policy enforcement, and hardened runners.
| name | chaos-engineering |
| type | skill |
| description | Design and run chaos experiments in Kubernetes — pod failures, network partitions, resource pressure with LitmusChaos and manual chaos. |
| related-rules | ["slo-policy.md","on-call-standards.md"] |
| allowed-tools | Read, Write, Edit, Bash |
Expertise: LitmusChaos experiments, manual K8s chaos, network partition testing, graceful degradation validation.
When designing chaos experiments, validating failover behavior, verifying SLO headroom, or onboarding a service to chaos testing.
1. Define steady state first
→ What does "working" look like? (SLI baseline: error rate < 0.1%, p99 < 200ms)
2. Hypothesize
→ "If 1/3 of pods die, the service will continue serving with p99 < 500ms"
3. Blast radius control
→ Start with staging. Start with 1 pod. Increase gradually.
4. Abort conditions
→ Auto-stop if error rate > 1% or p99 > 1s for > 2 min
5. Document and act
→ Passed = evidence of resilience. Failed = fix + re-test. Never just accept failure.
# ── Pod kill (test restart recovery) ──────────────────────────
kubectl delete pod <pod-name> -n production
# Watch: kubectl get pods -n production -l app=my-service -w
# Expected: new pod starts, readiness probe passes, 0 user-visible errors
# ── Kill all pods in deployment (test rolling restart recovery) ──
kubectl rollout restart deployment/my-service -n production
# Watch error rate during rollout
# ── Simulate OOMKill ──────────────────────────────────────────
kubectl exec -it <pod> -n production -- sh -c \
"dd if=/dev/zero of=/dev/shm/blob bs=1M count=600"
# Expected: pod OOMKilled, restarted, alert fired, no user impact
# ── Resource pressure on node ─────────────────────────────────
kubectl run stress --image=polinux/stress --restart=Never \
--overrides='{"spec":{"nodeSelector":{"kubernetes.io/hostname":"worker-01"}}}' \
-- stress --cpu 4 --vm 1 --vm-bytes 2G --timeout 120s
# ── Network partition: isolate a pod (Cilium + network policy) ──
# Apply a policy that drops all traffic from/to the pod
kubectl apply -f - << 'EOF'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: chaos-isolate, namespace: production }
spec:
podSelector: { matchLabels: { chaos-target: "true" } }
policyTypes: [Ingress, Egress]
EOF
kubectl label pod <pod> chaos-target=true -n production
# Observe: circuit breakers trip, retries, fallback behavior
# Cleanup:
kubectl delete networkpolicy chaos-isolate -n production
kubectl label pod <pod> chaos-target- -n production
# Install LitmusChaos
kubectl apply -f https://litmuschaos.github.io/litmus/litmus-operator-v3.0.0.yaml
# ── Pod Delete experiment ────────────────────────────────────
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: pod-delete-experiment
namespace: production
spec:
appinfo:
appns: production
applabel: app=order-service
appkind: deployment
engineState: active
chaosServiceAccount: litmus-admin
experiments:
- name: pod-delete
spec:
components:
env:
- name: TOTAL_CHAOS_DURATION
value: "60" # run for 60 seconds
- name: CHAOS_INTERVAL
value: "10" # delete a pod every 10s
- name: FORCE
value: "false" # graceful delete (test SIGTERM handling)
- name: PODS_AFFECTED_PERC
value: "33" # kill 33% of pods at a time
# ── Pod CPU Hog (test HPA scale-out) ─────────────────────────
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: cpu-hog-experiment
namespace: production
spec:
experiments:
- name: pod-cpu-hog
spec:
components:
env:
- name: CPU_CORES
value: "1"
- name: TOTAL_CHAOS_DURATION
value: "120"
- name: TARGET_PODS
value: "order-service-abc123"
1. Define scope (30 min)
- Which services? Which failure modes?
- What is acceptable impact? (staging or prod with traffic shadow)
2. Baseline measurement (10 min)
- Capture: RPS, error rate, p99, pod count
- Screenshot Grafana dashboard
3. Run experiments (60–90 min)
Experiment A: Kill 1 of 3 pods → observe recovery time
Experiment B: Saturate CPU on 1 pod → observe HPA response
Experiment C: Partition service from its DB → observe circuit breaker
4. Capture results per experiment
- Steady state maintained? (SLI threshold)
- Time to recovery
- Alerts fired? Correct ones?
- Runbook adequate?
5. Action items (20 min)
- For each failure: fix or accept with documentation
- Schedule follow-up experiments after fixes
# LitmusChaos: abort on SLO breach using steady-state hypothesis
spec:
jobCleanUpPolicy: delete
monitoring: true
# Prometheus probe: abort if error rate > 1%
experiments:
- name: pod-delete
spec:
probe:
- name: check-error-rate
type: promProbe
promProbe/inputs:
endpoint: http://prometheus:9090
query: |
sum(rate(http_requests_total{service="order-service",status=~"5.."}[2m]))
/ sum(rate(http_requests_total{service="order-service"}[2m]))
comparator:
type: float
criteria: "<="
value: "0.01" # abort if error rate exceeds 1%
mode: Continuous
runProperties:
probeTimeout: 10s
interval: 15s