返回技能列表

run-chaos-experiment

pjt222
更新于 6 days ago
19 次查看
17
2
17
在 GitHub 上查看
测试aitestingdesign

关于

This skill enables developers to design and execute chaos engineering experiments using Litmus or Chaos Mesh in Kubernetes. It performs controlled fault injection to test system resilience, validate failure hypotheses, and improve recovery processes. Use it before major launches, after architectural changes, or during resilience drills to proactively strengthen your system's reliability.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/run-chaos-experiment

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

行混驗

控注故以測且改系韌也。

  • 大釋前(負測)→用
  • 構改後(驗韌)→用
  • GameDay 或災復演→用
  • 驗故模假→用
  • SRE 熟度計畫→用

  • :Kubernetes 叢(Litmus 或 Chaos Mesh)
  • :穩態定(「常」貌)
  • :假設(如「一 pod 死,API 仍可用」)
  • :察棧(Prometheus、Grafana)量影
  • :回退計

一:定穩態與假

文錄常態:

## Steady State Definition

### Service: API Gateway
- **Availability**: 99.9% (< 0.1% error rate)
- **Latency**: p95 < 200ms
- **Throughput**: 1000 req/s

## Hypothesis
"If one API pod is killed, the remaining pods will handle the load with <5s
disruption and no increase in error rate."

得:明、可量之常與成準。

敗:穩態不可定→察不足,先增指。

二:限爆徑

縮驗以減險:

# chaos-config.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: chaos-testing

設護:

## Blast Radius Controls
### Environment
- **Scope**: Staging only (first 5 runs)
- **Production**: Only after 5 successful staging runs
- **Timing**: Business hours (09:00-17:00 local)
### Auto-Abort Conditions
- Error rate >10% for >30 seconds

得:驗有界、不傾全系。

敗:徑過大→縮範。一非關服始。

三:裝 Chaos Mesh

# Add Chaos Mesh Helm repo
helm repo add chaos-mesh https://charts.chaos-mesh.org
helm repo update

# Install Chaos Mesh
helm install chaos-mesh chaos-mesh/chaos-mesh \
  --namespace chaos-mesh \
  --create-namespace \
  --set dashboard.create=true \
  --set controllerManager.replicaCount=1

# Verify
kubectl get pods -n chaos-mesh

# Dashboard
kubectl port-forward -n chaos-mesh svc/chaos-dashboard 2333:2333

替:Litmus(中立):

kubectl apply -f https://litmuschaos.github.io/litmus/litmus-operator-v2.14.0.yaml
kubectl get pods -n litmus

得:Chaos Mesh 或 Litmus 行、面板可達。

敗:查 RBAC。混工需叢級權。

四:建行驗

例:Pod Kill(Chaos Mesh):

# pod-kill-experiment.yaml
apiVersion: chaos-mesh.org/v1alpha1
kind: PodChaos
metadata:
  name: api-pod-kill-test
  namespace: chaos-testing
spec:
  action: pod-kill
  mode: one
  selector:
    namespaces:
      - production
    labelSelectors:
      app: api-gateway
      chaos-enabled: "true"
  duration: "30s"

施驗:

kubectl apply -f pod-kill-experiment.yaml
kubectl get podchaos -n chaos-testing -w
kubectl describe podchaos api-pod-kill-test -n chaos-testing

察影於 Grafana:

rate(http_requests_total{status=~"5..", job="api"}[1m])
histogram_quantile(0.95, rate(http_request_duration_seconds_bucket{job="api"}[1m]))
rate(kube_pod_container_status_restarts_total{pod=~"api-.*"}[5m])

得:pod 死、k8s 重啟、服續微擾。

敗:誤率躍或服衰→停驗、查。

五:析果迭

書驗報:

# Chaos Experiment Report
**Hypothesis**: API stays available if one pod crashes
**Tool**: Chaos Mesh
## Results
- **Error Rate**: 0.1% → 2.3% (8s)
- **Recovery Time**: 8 seconds
## Hypothesis Outcome
**FAILED**: Error rate exceeded 1% threshold
## Improvements Made
1. Reduced readiness probe interval: 10s → 2s
2. Added pre-stop hook: 5-second sleep

記驗於日誌:

date,experiment,environment,status,error_rate_peak,recovery_time_s,outcome
2025-02-09,pod-kill-api,staging,complete,2.3%,8,failed

得:習得記、修施、後驗約。

敗:驗後無動→混工程為戲。優先修。

六:升至產(慎)

預驗常過後:

apiVersion: chaos-mesh.org/v1alpha1
kind: PodChaos
metadata:
  name: api-pod-kill-prod
spec:
  action: pod-kill
  duration: "10s"
  scheduler:
    cron: "0 10 * * 2"

產護:

kubectl create configmap chaos-killswitch \
  -n chaos-testing \
  --from-literal=enabled=true

得:產驗於低險窗、急停備。

敗:產驗致事故→立禁、覆盤。

  • 穩態與假明定
  • 爆徑限(境、範、時)
  • 混工裝測
  • 預驗成
  • 果文錄附指析
  • 修施
  • 後驗驗修
  • 產驗僅於 ≥ 5 預成後

  • 無假:「看何發」費時。必有假
  • 範過廣:殺諸 pod 為災復測,非韌測。始小
  • 產先:勿首於產。預先恆
  • 忽果:無動之混為戲。修所學
  • 警疲:混驗觸警。Grafana 註或靜期警
  • 無停計:失控時需急停。備之

  • setup-prometheus-monitoring
  • configure-alerting-rules
  • define-slo-sli-sla

GitHub 仓库

pjt222/agent-almanac
路径: i18n/wenyan-ultra/skills/run-chaos-experiment
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

evaluating-llms-harness

测试

该Skill通过60+个学术基准测试(如MMLU、GSM8K等)评估大语言模型质量,适用于模型对比、学术研究及训练进度追踪。它支持HuggingFace、vLLM和API接口,被EleutherAI等行业领先机构广泛采用。开发者可通过简单命令行快速对模型进行多任务批量评估。

查看技能

cloudflare-cron-triggers

测试

这个Claude Skill提供了关于Cloudflare Cron Triggers的完整知识库,用于通过cron表达式定时执行Workers。它支持配置周期性任务、维护作业和自动化工作流,并能处理常见的cron触发错误。开发者可以用它来设置定时任务、测试cron处理器,并集成Workflows和Green Compute功能。

查看技能

webapp-testing

测试

该Skill为开发者提供了基于Playwright的本地Web应用测试工具集,支持自动化测试前端功能、调试UI行为、捕获屏幕截图和查看浏览器日志。它包含管理服务器生命周期的辅助脚本,可直接作为黑盒工具运行而无需阅读源码。适用于需要快速验证本地Web应用界面和交互功能的开发场景。

查看技能

finishing-a-development-branch

测试

这个Skill用于开发分支完成后的集成决策,当代码实现完成且测试通过时,它会引导开发者选择合适的工作流。它首先验证测试状态,然后提供合并、创建PR或清理等结构化选项。核心价值在于确保代码质量的同时,标准化分支收尾流程。

查看技能