gitops-drift-agent
GitOps Drift Remediation Agent
Kubernetes 클러스터와 GitOps 저장소에 연결하여 승인되지 않은 상태 드리프트를 식별하고, 안전한 복구 전략을 생성하며, 자동화된 API 패치 또는 Pull Request를 실행하는 프로덕션급 자율 에이전트입니다.
목차
Related MCP server: kube-lint-mcp
개요
GitOps Drift Remediation Agent는 Kubernetes 리소스의 실시간 상태를 선언된 GitOps 소스 오브 트루스와 지속적으로 모니터링하는 자율적이고 정책 기반의 플랫폼입니다. 드리프트가 감지되면 에이전트는 적용 가능한 복구 정책을 평가하고, 최소 JSON Patch 작업을 계산한 후, Kubernetes API를 통해 직접 적용하거나 GitOps 저장소에 Pull Request를 생성합니다. 모든 작업에는 완전한 감사 추적이 포함됩니다.
핵심 원칙
최소 폭발 반경: 패치는 전체 리소스 교체가 아닌 가능한 가장 작은 diff로 계산됩니다
정책 우선: 모든 복구 작업은 위험 등급이 있는 구성 가능하고 버전 관리되는 정책에 의해 게이트키핑됩니다
불변 감사 로그: 모든 결정, 감지 및 변경은 암호화 컨텍스트와 함께 기록됩니다
GitOps 네이티브: 에이전트 자체가 GitOps로 관리되며 저장소로 PR을 발행합니다
MCP 지원: 모든 기능을 LLM 에이전트 통합을 위한 MCP 도구로 노출합니다
아키텍처
┌─────────────────────────────────────────────────────────────────────┐
│ GitOps Drift Remediation Agent │
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌────────────────────────┐ │
│ │ AST Differ │───▶│ Policy Engine│───▶│ Patch Engine │ │
│ │ │ │ │ │ │ │
│ │ • Deep diff │ │ • Risk tiers │ │ • JSON Patch RFC 6902 │ │
│ │ • Field │ │ • Allow/deny │ │ • K8s API apply │ │
│ │ tracking │ │ • Dry-run │ │ • PR generation │ │
│ │ • Severity │ │ • Approvals │ │ • Rollback support │ │
│ └─────────────┘ └──────────────┘ └────────────────────────┘ │
│ │ │ │ │
│ └──────────────────┴───────────────────────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ Audit Logger │ │
│ │ │ │
│ │ • Structured │ │
│ │ JSON logs │ │
│ │ • Event chain │ │
│ │ • Pino backend │ │
│ └─────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ MCP Server │ │
│ │ detect_drift │ list_policies │ remediate │ get_audit_trail │ │
│ └──────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
│ │
▼ ▼
┌─────────────┐ ┌───────────────┐
│ Kubernetes │ │ GitOps Repo │
│ Cluster(s) │ │ (Git/GitHub) │
└─────────────┘ └───────────────┘기능
기능 | 설명 |
드리프트 감지 | 실시간 vs 원하는 Kubernetes 리소스 상태의 심층 AST 기반 diff |
위험 분류 | 필드 경로별 자동 심각도 점수 산정(치명적 / 높음 / 중간 / 낮음) |
정책 엔진 | 허용/거부 규칙, 드라이런, 승인 게이트가 있는 선언적이고 버전 관리되는 정책 |
패치 엔진 | K8s 서버 사이드 apply를 지원하는 RFC 6902 JSON Patch 계산 |
GitOps PR | 드리프트 diff와 복구 근거가 포함된 자동 Pull Request 생성 |
감사 추적 | 전체 결정 체인이 포함된 불변 구조화 감사 로그 |
MCP 서버 | AI 에이전트 오케스트레이션을 위해 모든 에이전트 기능을 MCP 도구로 노출 |
CLI | 대화형 및 자동화된 운영을 위한 전체 기능 CLI |
설치
사전 요구 사항
Node.js >= 20.0.0
대상 클러스터 액세스가 구성된 kubectl
GitOps 저장소용 Git 자격 증명(PR 모드용)
소스에서 설치
git clone https://github.com/your-org/gitops-drift-remediation-agent.git
cd gitops-drift-remediation-agent
npm install
npm run build
npm link # optional: makes `drift-agent` available globally구성
모든 구성은 환경 변수 또는 구성 파일을 통해 전달됩니다.
환경 변수
변수 | 필수 | 기본값 | 설명 |
| 아니요 |
| kubeconfig 파일 경로 |
| 아니요 | current-context | 사용할 Kubernetes 컨텍스트 |
| 아니요 | — | PR 모드용 GitOps 저장소 URL |
| 아니요 |
| PR 대상 브랜치 |
| 아니요 | — | Git 제공자 토큰(GitHub/GitLab) |
| 아니요 |
| 복구 정책 구성 경로 |
| 아니요 |
| 감사 로그 출력 경로 |
| 아니요 |
| 로그 수준(debug/info/warn/error) |
| 아니요 |
| 전역 드라이런 모드 |
| 아니요 |
| MCP 서버 HTTP 포트 |
| 아니요 |
| 쉼표로 구분된 네임스페이스 필터 |
사용법
CLI 명령
# Detect drift across all namespaces
drift-agent detect --namespace production --output json
# Detect and auto-remediate with policy gate
drift-agent remediate --namespace production --policy strict --dry-run
# List active policies
drift-agent policy list
# Show audit trail for a resource
drift-agent audit --resource deployments/my-app --namespace production
# Start MCP server
drift-agent mcp-server --port 3000프로그래매틱 API
import { AstDiffer } from './src/detector/ast-differ';
import { RemediationPolicy } from './src/policy/remediation-policy';
import { PatchEngine } from './src/remediator/patch-engine';
const differ = new AstDiffer();
const drifts = await differ.detectDrift(liveResource, desiredResource);
const policy = new RemediationPolicy(policyConfig);
const decision = await policy.evaluate(drifts, resourceContext);
if (decision.approved) {
const engine = new PatchEngine(k8sClient);
await engine.applyRemediation(decision.patches, resourceRef);
}MCP 서버
에이전트는 모든 에이전트 기능을 LLM 기반 에이전트(Claude, GPT-4 등)를 위한 도구로 제공하는 MCP(Model Context Protocol) 서버를 노출합니다.
서버 시작
drift-agent mcp-server --port 3000
# or
npm run mcp:server사용 가능한 MCP 도구
도구 | 설명 |
| 리소스 또는 네임스페이스의 드리프트 감지 |
| 구성된 모든 복구 정책 나열 |
| 특정 정책에 대한 드리프트 평가 |
| 계산된 복구 패치 적용 |
| 리소스에 대한 감사 이벤트 검색 |
| 드리프트 복구를 위한 GitOps PR 생성 |
| 이전에 적용된 복구 롤백 |
MCP 클라이언트 구성
{
"mcpServers": {
"gitops-drift-agent": {
"url": "http://localhost:3000/mcp",
"transport": "http"
}
}
}정책 엔진
정책은 선언적으로 정의되며 복구 수명 주기의 모든 측면을 제어합니다.
정책 구조
apiVersion: drift.gitops.io/v1
kind: RemediationPolicy
metadata:
name: production-strict
spec:
riskTier: high
autoRemediate: false
requireApproval: true
dryRunFirst: true
rules:
- field: "spec.replicas"
action: restore
severity: high
- field: "spec.template.spec.containers[*].image"
action: block
severity: critical
excludeFields:
- "metadata.annotations['kubectl.kubernetes.io/last-applied-configuration']"
- "metadata.resourceVersion"
- "metadata.uid"감사 및 원격 측정
모든 에이전트 작업은 구조화된 JSON 형식으로 기록됩니다:
{
"timestamp": "2024-06-01T12:00:00.000Z",
"eventId": "evt_01J0ABC123",
"eventType": "DRIFT_DETECTED",
"severity": "high",
"resource": {
"kind": "Deployment",
"name": "my-app",
"namespace": "production",
"apiVersion": "apps/v1"
},
"drift": {
"field": "spec.replicas",
"desired": 3,
"live": 1,
"changeType": "edited"
},
"policy": {
"name": "production-strict",
"decision": "remediate",
"riskTier": "high"
},
"actor": {
"agentVersion": "1.0.0",
"kubeContext": "prod-cluster"
}
}개발
# Install dependencies
npm install
# Run in development mode (ts-node)
npm run dev -- detect --namespace default
# Type check only
npm run typecheck
# Lint
npm run lint
# Format
npm run format
# Build
npm run build테스트
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run in watch mode
npm run test:watch테스트는 tests/ 아래에 구성되며 Jest와 ts-jest를 사용합니다. Kubernetes 클라이언트 및 파일 시스템 작업에 대한 목(mock)이 제공됩니다.
보안 고려 사항
최소 권한: 에이전트는 대상 리소스에 대해
get,list,watch,patch권한만 필요합니다 —delete또는create는 절대 필요하지 않습니다기본 드라이런: 모든 정책 등급은 명시적으로 활성화될 때까지 기본적으로 드라이런입니다
승인 게이트: 높음 및 치명적 위험 변경은 정책을 통한 명시적 승인이 필요합니다
감사 불변성: 감사 로그는 추가 전용입니다. 로그 순환은 외부에서 처리됩니다
시크릿 마스킹: 시크릿 리소스 값은 로그와 PR에서 항상 마스킹됩니다
Kubeconfig 격리: 에이전트는 kubeconfig를 절대 변경하지 않습니다
기여
CONTRIBUTING.md를 참조하세요. 모든 기여에는 다음이 필요합니다:
80% 이상의 커버리지로 테스트 스위트 통과
새로운 린트 경고 없음
새로운 변경 경로에 대한 감사 로그 항목
새로운 복구 작업에 대한 정책 평가
라이선스
Apache 2.0 — LICENSE 참조.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides MCP multi-cluster Kubernetes management and operations. It can be integrated as an SDK into your own project and includes nearly 50 built-in tools covering common DevOps and development scenarios. Supports both standard and CRD resources.149MIT
- AlicenseNot gradedqualityAmaintenanceMCP server to lint and validate Kubernetes-related manifests(Helm, FluxCD, ArgoCD, Kustomize, etc.)MIT
- AlicenseNot gradedqualityDmaintenanceEnables Git repository operations and real-time monitoring via MCP tools, with support for WebSocket events, authentication, and observability.174MIT
- FlicenseNot gradedqualityBmaintenancePolicy-as-code gate for AI-SDLC, providing MCP tools to review prompts, diff tool manifests, vet MCP servers, and run evaluation suites for LLM agent repos.1
Related MCP Connectors
Remote MCP for Copilot CLI switch gate MCP, structured receipts, audit logs, and reviewer-ready evid
Monitor MCP servers, API contracts and AI outputs for schema drift. Alerts on breaking changes.
Control plane for autonomous software labor. Agents claim objectives over MCP with audit trail.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/felipeassis10/gitops-drift-remediation-agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server