# chaos-injection **Repository Path**: gavindev/chaos-injection ## Basic Information - **Project Name**: chaos-injection - **Description**: chaos-injection - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-11-02 - **Last Updated**: 2026-11-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # chaos-injection(节点级混沌注入) 从 shopdemo 项目中拆出的独立小项目,负责 **ChaosBlade operator 部署 + 节点级注入模板 + 权限**,后续承接从 shopdemo frontend 抽出的 chaos API。 ## 现状(2026-11-02) - operator / CRD / 工具 DaemonSet 已在集群 `chaosblade` 命名空间运行(operator `1.7.2`、tool `1.7.1`,4 节点各一个 tool Pod)。 - 注入编排目前仍在 shopdemo frontend 的 `/api/chaos/*` 中:直接调用 K8s API 创建/删除 `ChaosBlade` CR(SA `chaos-runner`)。 - **chaos-api 已落地、部署并完成前端切流**(`chaos-api/`,零依赖 Node 服务,契约兼容 `/api/chaos/*`,16 个单测通过);镜像 `ccr.ccs.tencentyun.com/lesson-demo/chaos-api:20261102-2017`,2026-11-02 部署到 `shopdemo` 命名空间(Pod 1/1);shopdemo frontend 已改为纯代理(镜像 `shopdemo-frontend:20261102-203327`,SA=`default`,仅 chaos-api 使用 `chaos-runner`)。切换步骤见 [`docs/shopdemo-switch.md`](docs/shopdemo-switch.md)。 ## 目录 ``` chaos-api/ # 节点级注入 API(从 shopdemo frontend 抽出,契约兼容) src/{scenarios,k8s,service,main}.js test/ # node --test,16 用例 Dockerfile deploy/ chaosblade-operator.yaml # Namespace / CRD / SA / ClusterRole / operator Deployment / tool DaemonSet / webhook Service chaos-runner-rbac.yaml # SA chaos-runner + ClusterRole shopdemo-chaos-runner / shopdemo-node-reader + 绑定 chaos-api.yaml # chaos-api Deployment + Service(image tag 为占位,发布前替换) scenarios/ cpu-load.yaml mem-load.yaml disk-fill.yaml combo-cpu-mem.yaml combo-disk-cpu.yaml docs/ api-contract.md # 与 shopdemo 的 /api/chaos/* 契约(拆分时保持兼容) shopdemo-switch.md # 前端切流步骤与回滚 ``` ## 部署 ```bash kubectl apply -f deploy/chaosblade-operator.yaml kubectl apply -f deploy/chaos-runner-rbac.yaml ``` ## 与 shopdemo 的关系 - shopdemo frontend 目前用 SA `chaos-runner` 直接建 CR;chaos-api 实现同一契约,按 [`docs/shopdemo-switch.md`](docs/shopdemo-switch.md) 切换后前端只做转发。 - **应用级故障注入**(`/fault`、TTL、loadgenerator 门控)属于 shopdemo 业务能力,不迁入本项目。 - 节点级实验会真实消耗 CPU/内存/磁盘;模板均带 `shopdemo.io/expires-at` 注解,演练后务必删除 CR 或等待自动过期。 ## 注意事项 - `Secret/chaosblade/chaosblade-webhook-server-cert` 未导出(operator 安装时生成);重建集群时确认 operator 可自签,或提前准备该证书。 - operator 镜像来自第三方 mirror `reajum3e8sw3fe01dq.xuanyuan.run`,如更换环境需同步镜像源。