{"id":41398553,"url":"https://github.com/helmcode/k8s-watchdog-ai","last_synced_at":"2026-01-23T13:03:08.474Z","repository":{"id":332777168,"uuid":"1133572425","full_name":"helmcode/k8s-watchdog-ai","owner":"helmcode","description":"Autonomous Kubernetes cluster observability with AI-powered","archived":false,"fork":false,"pushed_at":"2026-01-22T13:20:06.000Z","size":109,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-23T04:22:41.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helmcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-13T14:31:00.000Z","updated_at":"2026-01-23T04:01:04.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/helmcode/k8s-watchdog-ai","commit_stats":null,"previous_names":["helmcode/k8s-watchdog-ai"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/helmcode/k8s-watchdog-ai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmcode%2Fk8s-watchdog-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmcode%2Fk8s-watchdog-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmcode%2Fk8s-watchdog-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmcode%2Fk8s-watchdog-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helmcode","download_url":"https://codeload.github.com/helmcode/k8s-watchdog-ai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helmcode%2Fk8s-watchdog-ai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28692653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T11:01:27.039Z","status":"ssl_error","status_checked_at":"2026-01-23T11:00:26.909Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-23T13:02:40.471Z","updated_at":"2026-01-23T13:03:08.461Z","avatar_url":"https://github.com/helmcode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# K8s Watchdog AI 🐕\n\n\u003e Autonomous Kubernetes cluster observability with AI-powered weekly health reports\n\n[![Python](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![FastAPI](https://img.shields.io/badge/FastAPI-0.100+-green.svg)](https://fastapi.tiangolo.com/)\n\nAn intelligent Kubernetes monitoring agent that uses Claude AI to autonomously investigate cluster health, analyze metrics from Prometheus, and generate comprehensive weekly PDF reports delivered via Slack.\n\n## ✨ Features\n\n- 🤖 **AI-Powered Analysis**: Claude AI autonomously investigates cluster issues using direct Python tools\n- 📊 **Prometheus Integration**: Analyzes metrics to detect resource inefficiencies (optional)\n- 🔒 **Read-Only by Design**: All operations are read-only for safety\n- 📄 **PDF Reports**: Professional HTML reports converted to PDF via WeasyPrint\n- 📧 **Slack Integration**: Reports delivered via Slack with detailed tool usage information\n- 🗄️ **Historical Tracking**: SQLite storage for report history\n- 🚀 **REST API**: FastAPI server for on-demand report generation\n- ⚡ **Graceful Degradation**: Works with or without Prometheus\n\n## 🏗️ Architecture\n\n```\n┌─────────────────────────────────────────────────────┐\n│              Kubernetes Cluster                      │\n│                                                      │\n│  ┌──────────────────────────────────────────────┐   │\n│  │       K8s Watchdog AI (FastAPI)              │   │\n│  │                                              │   │\n│  │  ┌────────────────────────────────────┐     │   │\n│  │  │  Claude AI Agent                   │     │   │\n│  │  │  - Autonomous investigation        │     │   │\n│  │  │  - Tool selection \u0026 execution      │     │   │\n│  │  │  - Report generation              │     │   │\n│  │  └─────────┬──────────────────────────┘     │   │\n│  │            │                                 │   │\n│  │  ┌─────────▼──────────┐  ┌────────────────┐│   │\n│  │  │ Kubernetes Tools   │  │ Prometheus     ││   │\n│  │  │ - get pods/nodes   │  │ Tools          ││   │\n│  │  │ - describe         │  │ - query        ││   │\n│  │  │ - logs             │  │ - range query  ││   │\n│  │  │ - events           │  │ - memory/cpu   ││   │\n│  │  └────────────────────┘  └────────────────┘│   │\n│  │                                              │   │\n│  │  ┌────────────────────────────────────┐     │   │\n│  │  │  Report Generator \u0026 Storage        │     │   │\n│  │  │  - WeasyPrint (HTML → PDF)         │     │   │\n│  │  │  - SQLite (history)                │     │   │\n│  │  │  - Slack Files API v2              │     │   │\n│  │  └────────────────────────────────────┘     │   │\n│  └──────────────────┬───────────────────────────┘   │\n└────────────────────┼─────────────────────────────────┘\n                     │\n                     ▼\n              Slack Webhook\n```\n\n## 🚀 Quick Start\n\n### Prerequisites\n\n- Kubernetes cluster with kubectl access (or kubeconfig for local development)\n- Anthropic API key ([Get one here](https://console.anthropic.com/))\n- Slack webhook URL ([Create one](https://api.slack.com/messaging/webhooks))\n- Slack Bot Token and Channel ID for file uploads ([Create bot](https://api.slack.com/apps))\n- Prometheus running in cluster (optional - reports work without it)\n\n### Local Development with Docker Compose\n\n```bash\n# 1. Clone the repository\ngit clone https://github.com/helmcode/k8s-watchdog-ai.git\ncd k8s-watchdog-ai\n\n# 2. Copy and configure environment\ncp .env.example .env\n# Edit .env with your API keys and settings\n\n# 3. Run with docker-compose\ndocker-compose up -d\n\n# 4. Trigger report generation\ncurl -X POST http://localhost:8000/report\n\n# 5. Check status\ncurl http://localhost:8000/health\n\n# 6. View logs\ndocker-compose logs -f\n```\n\n### Deploy to Kubernetes with Helm\n\n```bash\n# 1. Store secrets in Vault (if using Vault)\nvault kv put helmcode_platform/k8s_watchdog_ai \\\n  ANTHROPIC_API_KEY=\"sk-ant-...\" \\\n  SLACK_WEBHOOK_URL=\"https://hooks.slack.com/...\" \\\n  SLACK_BOT_TOKEN=\"xoxb-...\" \\\n  SLACK_CHANNEL=\"C123456789\"\n\n# 2. Install with Helm\nhelm install k8s-watchdog-ai ./helm \\\n  --namespace watchdog-ai \\\n  --create-namespace \\\n  --values ./helm/values/prod.yaml\n\n# 3. Verify deployment\nkubectl get pods -n watchdog-ai\nkubectl logs -f deployment/k8s-watchdog-ai -n watchdog-ai\n```\n\nFor detailed Helm deployment instructions, see [helm/README.md](helm/README.md).\n\n### Deploy with ArgoCD\n\n```bash\n# Apply ArgoCD Application\nkubectl apply -f helm/argocd/application.yaml\n\n# Monitor deployment\nargocd app get k8s-watchdog-ai\n```\n\nFor ArgoCD configuration details, see [helm/argocd/README.md](helm/argocd/README.md).\n\n## ⚙️ Configuration\n\n| Variable | Required | Default | Description |\n|----------|----------|---------|-------------|\n| `ANTHROPIC_API_KEY` | ✅ | - | Claude API key |\n| `ANTHROPIC_MODEL` | ❌ | claude-sonnet-4-20250514 | AI model to use |\n| `SLACK_WEBHOOK_URL` | ✅ | - | Slack webhook for messages |\n| `SLACK_BOT_TOKEN` | ✅ | - | Bot token for file uploads |\n| `SLACK_CHANNEL` | ✅ | - | Channel ID (e.g., C123456789) |\n| `PROMETHEUS_URL` | ❌ | http://prometheus:9090 | Prometheus server URL |\n| `CLUSTER_NAME` | ❌ | default | Cluster identifier |\n| `CLIENT_NAME` | ❌ | default | Client/customer name |\n| `EXCLUDED_NAMESPACES` | ❌ | kube-system,kube-public,... | Namespaces to exclude |\n| `REPORT_LANGUAGE` | ❌ | spanish | Report language (spanish/english) |\n| `JOB_POLL_INTERVAL` | ❌ | 5 | Seconds between queue polls |\n| `JOB_MAX_RETRIES` | ❌ | 3 | Max retry attempts for failed jobs |\n| `SQLITE_PATH` | ❌ | /app/data/reports.db | SQLite database path |\n| `LOG_LEVEL` | ❌ | INFO | Logging level |\n\nSee [.env.example](.env.example) for complete list.\n\n## 📋 How It Works\n\n1. **FastAPI Server**: Runs continuously, exposing `/report` and `/health` endpoints\n2. **Trigger**: Can be called via HTTP POST or scheduled with Kubernetes CronJob\n3. **AI Investigation**:\n   - Claude receives a system prompt with available tools\n   - Agent autonomously decides what to investigate\n   - Makes iterative queries to Kubernetes and Prometheus (if available)\n4. **Analysis**: AI analyzes cluster health, resource usage, and metrics\n5. **Report Generation**: Creates HTML report, converts to PDF with WeasyPrint\n6. **Delivery**: Uploads PDF to Slack with detailed tool usage information\n7. **Storage**: Saves report to SQLite for history tracking\n\n### Example AI Investigation Flow\n\n```\nClaude: \"Let me check the overall pod status\"\n→ Calls: kubectl_get_pods(namespace=\"default\", all_namespaces=True)\n\nClaude: \"I see pod X has 15 restarts. Let me investigate\"\n→ Calls: kubectl_describe_pod(pod=\"X\", namespace=\"production\")\n→ Calls: kubectl_get_pod_logs(pod=\"X\", namespace=\"production\", tail=100)\n\nClaude: \"This looks like OOMKilled. Let me check memory metrics\"\n→ Calls: prometheus_check_pod_memory(pod=\"X\", namespace=\"production\")\n→ Calls: prometheus_query(query=\"container_memory_working_set_bytes{pod='X'}\")\n\nClaude: \"Memory usage is consistently above request. Recommending increase\"\n→ Generates HTML report with specific recommendations\n→ Report includes: issue analysis, metrics charts, action plan\n```\n\n### Tool Availability Detection\n\nThe system intelligently handles tool availability:\n\n```\n✅ Kubernetes API: 5 tool types used\n   • Tools: kubectl_describe_pod, kubectl_get_deployments, kubectl_get_events, ...\n\n❌ Prometheus: Connection failed\n   • Prometheus not available: All connection attempts failed\n   \n   ℹ️ Report generated using Kubernetes data only\n```\n\n## 📊 Report Structure\n\nReports include:\n\n1. **Executive Summary**: Overall health status (🟢🟡🔴)\n2. **Top Issues**: 3-5 critical problems with severity levels\n3. **Resource Analysis**: Over/under-provisioned workloads\n4. **Prometheus Metrics**: CPU, memory, disk usage (when available)\n5. **Action Plan**: Prioritized, actionable recommendations\n6. **Footer**: Generated by Watchdog AI - Helmcode\n\nThe PDF report is accompanied by a Slack message showing:\n- Report generation time\n- Data sources used (Kubernetes API, Prometheus)\n- Tool usage statistics\n- Connection status for each service\n\n## 🛠️ Development\n\n```bash\n# Install dependencies\npip install -e \".[dev]\"\n\n# Run locally (requires kubeconfig)\npython -m src.main\n\n# Format code\nblack src/\nruff check src/\n\n# Type check\nmypy src/\n\n# Build Docker image\ndocker build -t k8s-watchdog-ai:latest .\n```\n\n## 🔐 Security\n\n- **Read-only access**: All operations are read-only (get, list, watch, describe, logs)\n- **RBAC**: Minimal permissions required in Kubernetes\n- **No cluster modifications**: Agent cannot modify cluster state\n- **Secrets management**: Kubernetes secrets for sensitive data\n- **Connection errors**: Gracefully handles unavailable services\n\n## 📚 API Endpoints\n\n- `POST /report` - Generate and send report immediately (returns 202 Accepted)\n- `GET /health` - Health check endpoint\n- `GET /stats` - Report generation statistics\n\n## 📚 Documentation\n\n- [CLAUDE.md](CLAUDE.md) - Detailed technical documentation for AI assistants\n- [Architecture Overview](#architecture) - System design\n- [API Documentation](#api-endpoints) - REST endpoints\n\n## 🤝 Contributing\n\nContributions are welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Test thoroughly\n5. Submit a pull request\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) for details.\n\n## 🙏 Acknowledgments\n\n- [Anthropic Claude](https://www.anthropic.com/claude) - AI engine\n- [FastAPI](https://fastapi.tiangolo.com/) - Web framework\n- [WeasyPrint](https://weasyprint.org/) - PDF generation\n- [Kubernetes Python Client](https://github.com/kubernetes-client/python) - K8s integration\n\n---\n\n**Made with ❤️ by [Helmcode](https://helmcode.com)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelmcode%2Fk8s-watchdog-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelmcode%2Fk8s-watchdog-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelmcode%2Fk8s-watchdog-ai/lists"}