Argocd Deployment Analyzer — ArgoCD Deployment Analyzer
v1.0.0Analyze ArgoCD 应用 同步 状态, 检测 configuration drift, review manifests for security and best practices, and 诊断 同步 失败s.
运行时依赖
安装命令
点击复制本土化适配说明
Argocd Deployment Analyzer — ArgoCD Deployment Analyzer 安装说明: 安装命令:["openclaw skills install argocd-deployment-analyzer"]
技能文档
ArgoCD Deployment Analyzer 深入分析 ArgoCD 托管应用——检测同步漂移、诊断同步失败、审计清单安全、审查同步策略,并依据生产最佳实践验证 ArgoCD 配置。将 ArgoCD 运维噪音转化为可执行结论。
使用场景: “analyze argocd apps” “why is my argocd app out of sync” “review argocd config” “audit gitops deployments” “diagnose sync failure” 或当 ArgoCD 应用降级、漂移、配置错误时。
前置条件 Agent 会检查 ArgoCD 访问权限: # CLI 访问 argocd version --client # 已登录 argocd account get-user-info # 或:kubectl 可访问 ArgoCD 命名空间 kubectl get applications.argoproj.io -n argocd # 或:ArgoCD API 访问 curl -s https://argocd.example.com/api/v1/applications \ -H "Authorization: Bearer $ARGOCD_TOKEN" | jq '.items | length'
用法 提供以下一项或多项:
- Application name:指定 ArgoCD 应用(如 production/api-server)
- Project name:分析某项目下全部应用
- Scope:all 分析所有应用
- Focus area:sync、security、health、drift、config 或 all
示例调用:
- 分析 payments-service 为何持续 OutOfSync
- 对 production 项目内所有 ArgoCD 应用做安全审计
- 审查 ArgoCD ApplicationSet 配置是否符合最佳实践
工作原理 步骤 1:应用清单 获取全部 ArgoCD 应用全景: # 列出所有应用及状态 argocd app list -o json | jq '[.[] | { name: .metadata.name, project: .spec.project, syncStatus: .status.sync.status, healthStatus: .status.health.status, repo: .spec.source.repoURL, path: .spec.source.path, targetRevision: .spec.source.targetRevision, destination: .spec.destination.server, namespace: .spec.destination.namespace, syncPolicy: .spec.syncPolicy }]' # 或通过 kubectl kubectl get applications.argoproj.io -n argocd -o json | jq '[.items[] | { name: .metadata.name, sync: .status.sync.status, health: .status.health.status }]'
应用分类:
- Healthy + Synced:无需操作
- Healthy + OutOfSync:发现漂移,需调查
- Degraded:健康检查失败
- Progressing:同步中,检查是否卡住
- Missing:目标资源不存在
- Unknown:ArgoCD 无法判定状态
步骤 2:同步漂移分析 对每个 OutOfSync 应用,定位漂移内容与原因: # 比较 live 与 desired 状态 argocd app diff --local-repo-root /path/to/repo # 资源级详细同步状态 argocd app get -o json | jq '{ syncStatus: .status.sync.status, revision: .status.sync.revision, comparedTo: .status.sync.comparedTo, resources: [.status.resources[] | select(.status != "Synced") | { kind: .kind, name: .name, namespace: .namespace, status: .status, health: .health.status, message: .health.message }] }' # 查看同步历史模式 argocd app get -o json | jq '[.status.history[] | { revision: .revision[:8], deployedAt: .deployedAt, source: .source.path }]'
常见漂移原因:
- 手动 kubectl 编辑
- Mutating webhooks 注入
- HPA 副本数冲突
- 控制器管理字段更新
- CRD 默认值注入
- Helm values.yaml 与渲染结果不一致
步骤 3:同步失败诊断 同步操作失败时,定位根因: # 获取同步操作结果 argocd app get -o json | jq '.status.operationState | { phase: .phase, message: .message, startedAt: .startedAt, finishedAt: .finishedAt, syncResult: .syncResult.resources | map(select(.status != "Synced")) }' # 检查资源级错误 argocd app resources --orphaned # 查看目标命名空间事件 kubectl get events -n --sort-by='.lastTimestamp' | tail -20
失败类别与典型修复:
- RBAC 禁止:修复 ArgoCD SA 权限
- Schema 校验失败:对照 CRD/API 修正清单
- 命名空间缺失:创建或开启自动创建
- 资源冲突:检查重复管理
- 配额超限:申请扩容或减少请求
- 不可变字段:删除重建
- 依赖顺序:添加 sync waves
步骤 4:健康检查分析 评估应用健康并识别降级组件: # Hea