cognis-digital/gitopsd
GitHub: cognis-digital/gitopsd
一款零依赖的 GitOps 偏差检测 CLI,对比 Kubernetes 声明 manifest 与集群实时状态快照,输出字段级偏差报告与 reconcile 计划。
Stars: 0 | Forks: 0
# gitopsd
**GitOps 偏差检测,零依赖。** 对比您声明的 Kubernetes
manifest(git 中的事实来源)与实时的集群状态,并获取清晰的
偏差报告以及 reconcile 计划 —— 将核心的 GitOps 循环封装为单个 CLI。
**Cognis Neural Suite** 的一部分。仅使用标准库;自身不需要集群
访问权限,因此可以在 CI 和 air-gapped 审查工作流中运行。
## 为什么使用
GitOps 正在成为团队运行 Kubernetes 的默认方式,但您并不总是
希望仅在集群内安装一个完整的 controller 来*回答这个问题*:“实时状态是否与
git 匹配?”。gitopsd 可以通过 manifest 目录和状态快照
(`kubectl get ... -o json`)来回答这个问题,且无任何依赖。
## 命令
```
# 报告 drift(缺失 / 多余 / drifted / in-sync)+ 一个 reconcile 计划。
python -m gitopsd diff ./manifests ./live-snapshot.json --prune
# 仅 apply/delete 计划。
python -m gitopsd plan ./manifests ./live-snapshot.json --prune
# 为 pipeline 设置门禁:如果发生任何 drift,则以非零状态退出。
python -m gitopsd diff ./manifests ./live-snapshot.json --fail-on-drift
# 作为本地 MCP 服务器运行(stdio JSON-RPC)。
python -m gitopsd mcp
```
## gitopsd 的与众不同之处
- **无噪音的 diffs。** 忽略 `status` 和服务器管理的元数据
(`uid`、`resourceVersion`、`managedFields`、last-applied 注解),让您
看到*真正的*偏差,而不是集群的记录信息。
- **字段级偏差。** 准确告知哪些路径发生了更改以及更改前后的内容。
- **Reconcile 计划。** 输出有序的 apply/delete 计划;`--prune` 会标记
未声明的资源。
- **原生支持 MCP**(`diff` / `plan`)以及一个可选的本地 fleet AI hook(默认
关闭),用于总结偏差并标记风险最高的更改。
- **与 air-gap 套件配合使用** — 在使用
[airlock](https://github.com/cognis-digital/airlock) 打包之前审查偏差。
## 测试
```
python -m pytest -q # or: python -m unittest discover -s tests
```
## 互操作性
`gitopsd` 可与 300 多个工具的 Cognis 套件组合使用 —— JSON 输入/输出以及共享的
兼容 OpenAI 的 `/v1` 主干网络。请参阅 **[INTEROP.md](INTEROP.md)** 了解
套件图谱、组合模式和参考技术栈。
## 集成
通过
[`cognis-connect`](https://github.com/cognis-digital/cognis-connect) 将 `gitopsd` 的发现转发至 STIX/MISP/Sigma/Splunk/Elastic/Slack/webhooks。请参阅 **[INTEGRATIONS.md](INTEGRATIONS.md)**。
## 许可证
Cognis Open Collaboration License (COCL) 1.0 — 请参阅 [`LICENSE`](LICENSE)。
© 2026 Cognis Digital LLC。原始 Cognis 作品;不包含任何第三方代码、名称或
品牌。
## 领域
**主要领域:** Intelligence & OSINT · **JTF MERIDIAN 部门:** NULLBYTE · BLACK CELL
**主题:** `cognis` `osint` `intelligence` `recon` `kubernetes`
**Cognis Neural Suite** 的一部分 — 包含 300 多个开源工具,跨越 JTF MERIDIAN 指挥结构下的 12 个领域。请参阅 [GitHub 上的套件](https://github.com/cognis-digital) 和 [jtf-meridian](https://github.com/cognis-digital/jtf-meridian) 了解各部分如何组合在一起。
## 使用说明 — 逐步指南
`gitopsd` 会将声明的 Kubernetes manifests 与实时状态快照进行对比,并输出偏差报告以及 reconcile 计划 — 其自身不需要集群访问权限。
1. **安装**(纯标准库,Python 3.10+):
pip install "git+https://github.com/cognis-digital/gitopsd.git"
2. **使用 kubectl 拍摄实时状态快照**,然后将其与您的 manifests 进行对比(`--prune` 标记未声明的实时资源,`--ignore` 跳过字段 glob):
kubectl get deploy,svc -o json > live-snapshot.json
gitopsd diff ./manifests ./live-snapshot.json --prune --ignore spec.replicas
3. **仅获取 reconcile 计划**(有序的 apply/delete 步骤):
gitopsd plan ./manifests ./live-snapshot.json --prune
4. **使用输出** — 使用 `--format json` 供工具使用,或为发生偏差的资源生成 RFC-6902 补丁:
gitopsd diff ./manifests ./live-snapshot.json --format json
gitopsd patch ./manifests ./live-snapshot.json
5. **CI 门禁** — 只要实时状态与 git 不同,`--fail-on-drift` 就会以非零状态退出:
gitopsd diff ./manifests ./live-snapshot.json --fail-on-drift
或者将其作为本地 MCP 服务器运行(stdio JSON-RPC):`gitopsd mcp`。
标签:GitOps, MCP, Pandas, 子域名突变, 逆向工具, 配置漂移检测