██╗ ██╗██████╗ ███╗ ███╗ ██║ ██╔╝██╔══██╗████╗ ████║ █████╔╝ ██║ ██║██╔████╔██║ ██╔═██╗ ██║ ██║██║╚██╔╝██║ ██║ ██╗██████╔╝██║ ╚═╝ ██║ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝
Monitor Docker containers and Kubernetes pods from a single terminal interface.
KDM (Kubernetes Docker Monitor) is a lightweight CLI tool that automatically detects and monitors running Docker containers and Kubernetes pods. It provides real-time health status, live dashboards, log fetching, and alert notifications — all from your terminal.
Unlike tools that focus on a single runtime (k9s for Kubernetes or lazydocker for Docker), KDM gives you a unified view of both worlds.
| Feature | Description |
|---|---|
| Auto-Detection | Automatically discovers Docker containers, Kubernetes pods, and Minikube status |
| Interactive AI Copilot | 4-tab terminal shell (kdm copilot) with live /pods, /containers, /analyze, /investigate, /diff, and /health slash commands |
| Unified Runner View | Combined table of Docker and Kubernetes workloads (kdm show runners) |
| Health Monitoring | Color-coded CPU, memory, pod, and container health with continuous watch mode (kdm health) |
| Live Watch Dashboard | Real-time Ink TUI (kdm watch) with log snapshots (l), Copilot launch (t), AI diagnosis (a), and safe restarts (r) |
| Log Fetching | Searchable, live-streaming logs (kdm logs) with Docker-to-Kubernetes fallback |
| Multi-Agent SRE | Autonomous Python + Ollama council (kdm analyze --multi-agent) backed by a 4-tier Graceful Degradation Ladder |
| AI Diagnostics | Scan 22 built-in Kubernetes analyzers plus KEDA, Kyverno, and Prometheus integrations (kdm analyze) |
| Codebase Investigator | Correlates live cluster symptoms (OOMs, JVM -Xmx heap limits, missing secretKeyRef keys) with local YAML manifests and code |
| Safe Remediation | Declarative Zod-validated K8s/Docker tools guarded by explicit [y/N] confirmation (SafetyPrompt) and parameterized execFile auditing |
| AI Providers | Configure 14 AI backends (kdm auth) including OpenAI, Anthropic, Google Gemini (@google/genai), Vertex, Ollama, Bedrock, Groq, WatsonX, and OCI GenAI |
| Local Cache | SHA-256 local explanation cache (kdm cache) to save API tokens and reduce latency |
| Dynamic Filters & CRDs | Customize active filters (kdm filters) or add external script/webhook analyzers (kdm custom-analyzer) |
| MCP & HTTP Server | Localhost REST API or JSON-RPC 2.0 Model Context Protocol (MCP) stdio server (kdm serve) |
| Alert Notifications | Send failure alerts via Discord webhook or email SMTP (kdm config setup) |
npm install -g kdm-clinpx kdm-clinpm install kdm-cli
npx kdmnpm install kdm-cli adds the kdm executable to the project at
./node_modules/.bin/kdm; it does not add it to your system PATH. Use
npx kdm from that project, or choose the global installation above to run
kdm from any directory.
Requirements:
- Node.js >= 20
- Docker daemon (for container features)
- Kubernetes cluster or Minikube (for pod features)
Once installed, run KDM with no arguments to display the welcome banner, connection status, and available commands:
kdmYou should see output similar to:
Docker: ✔ CONNECTED (3 running)
Kubernetes: ✔ CONNECTED (5 running)
Minikube: ✔ RUNNING
Display running containers, pods, or both in a formatted table.
kdm show runners # Combined view: pods + containers
kdm show pods # Kubernetes pods only
kdm show containers # Docker containers only
kdm show minikube # Minikube profile statusCheck and monitor the health of your workloads with color-coded output.
kdm health all # Both pods and containers
kdm health pods # Pods only
kdm health containers # Containers only
kdm health all -w # Watch mode: auto-refresh every 5 seconds
kdm health pods -w -i 2 # Watch mode: refresh every 2 secondsMonitor all workloads in real time with an interactive terminal dashboard.
kdm watch # Opens Ink-based live dashboard (t: Copilot, a: AI diagnose, l: logs, r: restart, Ctrl+C: exit)Launch a 4-tab terminal AI Copilot (Monitor, Agents, Diffs, Settings) wired directly to live cluster tools and codebase investigation.
kdm copilot # Opens Copilot shell on tab 1 (Monitor)
kdm copilot checkout-api -t 2 # Pre-scope to a workload and open Agents tabInside Copilot, run live slash commands including /pods [-n <namespace>], /containers, /watch, /analyze [pod-name], /investigate, /diff, /health, /help, /clear, and /quit.
Retrieve and search live container or pod logs. Docker is tried first; Kubernetes is used as a fallback.
kdm logs # Interactive searchable resource picker and log viewer
kdm logs <name> # Open logs directly for container or pod nameScan your Kubernetes cluster across 22 built-in analyzers (plus KEDA, Kyverno, Prometheus, and custom analyzers) for workload issues and get AI-powered troubleshooting advice or multi-agent root-cause synthesis.
kdm analyze # Interactive AnalyzeDashboard in TTY / report in non-TTY
kdm analyze -n default # Analyze resources in the 'default' namespace only
kdm analyze --multi-agent # Run autonomous multi-agent SRE council with local Ollama models
kdm analyze deployment/checkout-api --multi-agent # Target specific workload for multi-agent root-cause triaging
kdm analyze --multi-agent --council-timeout 180000 # Override Python council timeout (ms)
kdm analyze --explain # Run diagnostics and fetch single-prompt AI explanation
kdm analyze --explain --backend google-gemini # Force specific AI backend provider
kdm analyze --explain --anonymize --export-audit report.md # Redacted incident report export
kdm analyze --output json # Output results in structured JSON formatKDM v4.0.0 features an autonomous Multi-Agent SRE Council running 100% locally via Ollama. Instead of relying on a single static LLM prompt, KDM coordinates domain-specialist agents in parallel to collect evidence, evaluate deterministic failure rules, correlate observations, formulate root-cause hypotheses, and safely apply verified remediations.
flowchart TD
CLI["CLI Command: kdm analyze --multi-agent"] --> Collect["1. Evidence Collector\n(Pods, Events, Logs, Node Metrics)"]
Collect --> RuleEngine{"2. Deterministic Rule Engine\n(< 5ms fast-path check)"}
RuleEngine -- Conclusive Match --> Instant["Instant Diagnosis\n(Zero LLM Overhead)"]
RuleEngine -- Complex Failure --> Council["Specialist Agent Council\n(Parallel Execution)"]
subgraph Specialists["2. Specialist Council"]
Council --> Runtime["Runtime & Log Agent\n(Exit codes, panic traces, crashes)"]
Council --> Config["Config & Dependency Agent\n(Limits, probes, secrets, ConfigMaps)"]
Council --> Resource["Cluster & Resource Agent\n(Node memory/disk pressure, capacity)"]
end
Runtime --> Correlate["3. Correlate & Validate\n(Lead SRE Synthesizer)"]
Config --> Correlate
Resource --> Correlate
Correlate --> Validator{"Cross-Agent Validator\n(Contradiction Check)"}
Validator -- Validated --> Consensus["4. Consensus Diagnosis\n(Root Cause + High Confidence + Solution)"]
Instant --> Consensus
Consensus --> TUI["Live Ink TUI Dashboard"]
TUI --> SafetyGate{"5. Remediation Safety Gate [y/N]\n(Destructive Command Policy)"}
SafetyGate -- "Confirmed [y]" --> Executor["Parameterized Executor\n(Stdout/Stderr + Audit Trail)"]
SafetyGate -- "Aborted [n]" --> Aborted["Remediation Aborted Safely"]
Executor --> Verify["6. Post-Fix Verification\n(Pod Ready 1/1, Rollout, Zero Restarts)"]
Verify --> Done["Remediation Successful!"]
$ kdm analyze deployment/checkout-api --multi-agent
1. COLLECT
✓ Kubernetes evidence collected (14 items)
2. INVESTIGATE
✓ Runtime Agent (detected exit code 137)
✓ Config Agent (checked limits and probes)
✓ Resource Agent (checked node memory pressure)
3. CORRELATE & VALIDATE
✓ Lead Investigator formulated root-cause hypothesis
✓ Validator confirmed: no contradictions
4. DIAGNOSIS
Root Cause: Container exceeded 256Mi memory limit under peak load
Confidence: HIGH · 96%
5. REMEDIATION
Action: Increase memory limit (256Mi → 512Mi)
Command: kubectl set resources deployment checkout-api --limits=memory=512Mi
Apply? [y/N]: y
6. VERIFY
✓ Deployment rolled out
✓ Pod Ready: 1/1
✓ No new restarts detected
Remediation successful.
| Option | Method | Description |
|---|---|---|
--multi-agent |
CLI Flag | Enables Multi-Agent Council for kdm analyze |
--model <model> |
CLI Flag | Overrides model (e.g. llama3.1, qwen2.5-coder, gemini-2.5-flash) |
--council-timeout <ms> |
CLI Flag | Overrides Python council timeout in milliseconds (default 120000) |
--export-audit <path> |
CLI Flag | Exports redacted Markdown or JSON incident audit report |
multi_agent: true |
Config Store | Persist opt-in via kdm config set multi_agent true |
KDM_MULTI_AGENT=true |
Environment | Set environment variable for CI/CD or non-interactive automation |
KDM is engineered for mission-critical reliability. If local Ollama, Python, or cloud backends fail or timeout, KDM automatically falls back down the degradation ladder without throwing unhandled exceptions:
- Step 1: Multi-Agent Council — Full parallel multi-agent triage with local Ollama models.
- Step 2: Deterministic Rule Engine — Evaluates rules with zero LLM overhead for canonical failure signatures (
OOMKilled,CrashLoopBackOff,ImagePullBackOff,ProbeFailure,Scheduling). - Step 3: Legacy AI Client — Single-prompt cloud provider completions (OpenAI, Claude, Gemini, Azure).
- Step 4: Raw Kubernetes Summary — Structured, formatted workload error diagnostics with zero AI required.
Manage AI backend settings and credentials. KDM supports 14 configured AI backends (openai, ollama, anthropic, noop, customrest, azure-openai, cohere, google-gemini, google-vertex, amazon-bedrock, huggingface, groq, ibm-watsonx, oci-genai), plus modern Google GenAI (@google/genai, aliased as google-genai / gemini).
kdm auth add -b openai -m gpt-4o -p <key> # Configure OpenAI gpt-4o with API key
kdm auth add -b google-gemini -m gemini-2.5-flash -p <key> # Configure Gemini
kdm auth add -b ollama -m llama3.1 # Configure local Ollama llama3.1
kdm auth list # List configured AI backends and settings
kdm auth default ollama # Set default active AI backend
kdm auth remove openai # Remove backend credentials from config
kdm auth update ollama -t 0.2 # Update settings (e.g. set temperature to 0.2)KDM caches AI explanations locally to save API tokens and reduce network latency.
kdm cache list # List all cached AI explanation keys
kdm cache get <key> # Retrieve cached text for a key
kdm cache remove <key> # Delete a specific cached entry
kdm cache purge # Clear all cached AI explanationsBy default, KDM runs all core resource analyzers. You can customize which analyzers are active using the interactive checklist dashboard or CLI subcommands:
kdm filters # Open interactive checklist dashboard with instant persistence
kdm filters list # List active filters and available inactive ones
kdm filters add Ingress # Add Ingress analyzer to active default filters list
kdm filters remove Ingress # Remove analyzer from active list (falls back to defaults)Register custom scripts/commands or HTTP webhooks to analyze arbitrary custom resources (CRDs) like Kyverno, KEDA, and Prometheus.
kdm custom-analyzer # Interactive rule manager (TTY required)
kdm custom-analyzer add keda --command "kubectl get scaledobjects -A -o json" # Add custom analyzer command
kdm custom-analyzer add my-webhook --url "https://api.my-org.internal/check" # Add custom HTTP analyzer
kdm custom-analyzer list # List all custom analyzers
kdm custom-analyzer remove keda # Remove custom analyzerRun KDM in server mode. KDM can run as a standard REST API or as a Model Context Protocol (MCP) server, enabling seamless integration with AI agents (like Claude Desktop).
kdm serve --port 8080 # Start KDM HTTP REST server on port 8080
kdm serve --mcp # Start KDM JSON-RPC MCP server over stdioSet up notification services and manage configuration interactively.
kdm config setup # Interactive setup (Discord webhook / Email SMTP)
kdm config list # Show current configuration
kdm config set <key> <value> # Set a specific value
kdm config clear # Clear all configurationkdm --help # Show all commands and options
kdm <command> --help # Show help for a specific commandKDM stores configuration locally using the conf package.
| OS | Path |
|---|---|
| macOS | ~/Library/Application Support/kdm-cli |
| Linux | ~/.config/kdm-cli |
| Windows | %APPDATA%\kdm-cli |
| Variable | Description |
|---|---|
GEMINI_API_KEY, GOOGLE_GENAI_API_KEY, GOOGLE_API_KEY |
API key lookup order for GoogleGenAIClient (@google/genai) |
KDM_MULTI_AGENT |
Set true or 1 to enable Multi-Agent Council mode globally |
KDM_COUNCIL_TIMEOUT_MS |
Override Python Multi-Agent Council timeout in milliseconds (default 120000) |
KDM_ALLOW_LOCAL_AGENTS |
Set 1 or true in local dev to allow CWD agents/council.py resolution |
KDM_SMTP_PASSWORD |
SMTP password (must be set at runtime; never stored in config) |
NODE_ENV |
Setting development enables local CWD agent script resolution |
Set up alerts to be notified when containers restart or pods enter failure states (CrashLoopBackOff, ImagePullBackOff, Failed, etc.).
kdm config setupSupports:
- Discord — via webhook URL
- Email (SMTP) — via SMTP credentials
Alerts are rate-limited with a configurable cooldown (default: 300 seconds).
kdm config set alert_cooldown 600 # 10 minutes between alertsKDM automatically checks for failure conditions and sends notifications when configured:
| Condition | Severity | Source |
|---|---|---|
| Container restarting | Warning | Docker |
| Container non-zero exit | Critical | Docker |
Pod phase is Failed |
Critical | Kubernetes |
CrashLoopBackOff |
Critical | Kubernetes |
ImagePullBackOff |
Critical | Kubernetes |
CreateContainerConfigError |
Critical | Kubernetes |
| Technology | Purpose |
|---|---|
| TypeScript + Node.js | Runtime and language (Node >= 20) |
| Commander.js | CLI framework and argument parsing |
| @google/genai | Modern Google Gemini SDK, thought-preserving sessions, and function calling |
| Zod | Runtime schema validation and OpenAPI tool schema conversion |
| dockerode | Docker daemon API client |
| @kubernetes/client-node | Kubernetes API client |
| Python 3 + Ollama | Multi-agent SRE council and local LLM execution |
| Ink + React | Interactive terminal UI (CopilotShell, dashboards, and SafetyPrompt) |
| chalk | Terminal string coloring |
| cli-table3 | Table rendering |
| conf | Persistent configuration |
| nodemailer | Email alerts |
| tsup | High-performance bundler |
| Vitest | Unit and end-to-end integration test runner |
- Command Reference — Complete CLI flags, Copilot slash commands, TUI shortcuts, HTTP/MCP endpoints, and env vars
- Architecture & Internals — How KDM works end-to-end (analyzers, Multi-Agent Council, 4-tier ladder, declarative tools, and safety gate)
- What Is KDM? — Introduction, core capabilities, setup, and concepts
- Coding Style Guide — Code health thresholds and style rules
- Documentation Index & Changelog
- Multi-Agent Architecture Plan
- Contribution Guide
- Code of Conduct
- Security Policy
.
├── bin/ # CLI executable entrypoint (kdm)
├── config/ # Default specialist model routing (agents.yaml)
├── src/
│ ├── commands/ # Commander CLI command definitions
│ ├── analyzers/ # 22 built-in Kubernetes & custom resource analyzers
│ ├── integrations/ # Optional KEDA, Kyverno, and Prometheus analyzers
│ ├── analysis/ # Core analysis pipeline, preflight probes, 4-tier fallback
│ ├── rules/ # Deterministic offline Kubernetes rule engine
│ ├── ai/ # 14 AI backends + GoogleGenAIClient / GeminiSession
│ ├── agent/ # AgentRegistry, AgentTool, CodebaseInvestigator, Python bridge
│ ├── tools/ # Declarative Zod-validated Kubernetes & Docker tools
│ ├── remediation/ # SafetyPrompt [y/N] confirmation gate & parameterized executor
│ ├── server/ # Localhost HTTP API & stdio MCP server
│ ├── ui/ # React Ink TUI dashboards & CopilotShell
│ ├── config/ # Persistent store, schema validation, legacy migration
│ ├── cache/ # Local explanation file cache provider
│ ├── monitor/ # Alert delivery (Discord webhooks / SMTP email)
│ └── __tests__/ # Vitest unit, baseline, and e2e test suites
├── agents/
│ ├── council.py # Python + Ollama multi-agent council entrypoint
│ ├── core/ # Evidence model, event streaming, sanitization
│ ├── specialists/ # Domain specialists (runtime, config, resource)
│ ├── orchestration/ # Multi-agent orchestration and tool loop
│ ├── synthesis/ # Consensus hypothesis formulation & investigation
│ ├── validation/ # Cross-agent validation checks
│ ├── remediation/ # Planner, safety policy, post-fix verification
│ ├── rules/ # Python deterministic rule evaluators
│ ├── tools/ # Python Kubernetes & Docker runtime tools
│ └── tests/ # Pytest / unittest suite for Python agents
└── docs/
├── guides/ # Architecture, commands, coding style, intro guides
├── releases/ # Versioned changelogs (v*.md)
└── plans/ # Architecture plans & design specifications
We welcome contributions of all kinds — bug reports, feature suggestions, and pull requests.
Please read our Contribution Guide and Code of Conduct before getting started.
git clone https://github.com/KDM-cli/kdm-cli.git
cd kdm-cli
npm install
npm run dev # Watch mode for development
npm test # Run test suite
npm run build # Production buildThanks goes to these wonderful people (emoji key):
Yuvraj Sarathe 🚇 📖 |
Utkarsh Patrikar 💻 🚇 🚧 |
blut-agent 💻 📖 🛡️ |
Rishiraj Pathak 💻 |
fizyxbt 🛡️ |
Akansha Gore 💻 |
Kunal Khare 💻 |
Suprovo Mallick (DYNO) 💻 |
Luochenchen 💻 |
Channa Karawita 💻 |
This project follows the All Contributors specification. Contributions of any kind are welcome!
GNU Affero General Public License v3.0 — See LICENSE for full terms.
Maintained by KDM-cli · Built with ❤️ by the community