{"id":36947458,"url":"https://github.com/kaskol10/karpenter-optimizer","last_synced_at":"2026-01-26T18:09:36.163Z","repository":{"id":327232455,"uuid":"1107697631","full_name":"kaskol10/karpenter-optimizer","owner":"kaskol10","description":"💰 Cost optimization tool for Karpenter NodePools. Analyzes Kubernetes cluster usage and provides AI-powered recommendations to reduce AWS EC2 costs while maintaining performance.","archived":false,"fork":false,"pushed_at":"2026-01-01T21:23:16.000Z","size":64920,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-03T00:55:06.755Z","etag":null,"topics":["aws","cost-optimization","docker","ec2","go","helm","karpenter","karpenter-tools","kubernetes","kubernetes-tools","node-pool","react"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaskol10.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-12-01T13:48:12.000Z","updated_at":"2025-12-30T23:47:08.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kaskol10/karpenter-optimizer","commit_stats":null,"previous_names":["kaskol10/karpenter-optimizer"],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/kaskol10/karpenter-optimizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaskol10%2Fkarpenter-optimizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaskol10%2Fkarpenter-optimizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaskol10%2Fkarpenter-optimizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaskol10%2Fkarpenter-optimizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaskol10","download_url":"https://codeload.github.com/kaskol10/karpenter-optimizer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaskol10%2Fkarpenter-optimizer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28384112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T10:34:27.190Z","status":"ssl_error","status_checked_at":"2026-01-13T10:34:26.289Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["aws","cost-optimization","docker","ec2","go","helm","karpenter","karpenter-tools","kubernetes","kubernetes-tools","node-pool","react"],"created_at":"2026-01-13T11:38:50.081Z","updated_at":"2026-01-26T18:09:36.156Z","avatar_url":"https://github.com/kaskol10.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Karpenter Optimizer\n\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kaskol10/karpenter-optimizer)](https://goreportcard.com/report/github.com/kaskol10/karpenter-optimizer)\n[![CI](https://github.com/kaskol10/karpenter-optimizer/workflows/CI/badge.svg)](https://github.com/kaskol10/karpenter-optimizer/actions)\n[![Release](https://img.shields.io/github/release/kaskol10/karpenter-optimizer.svg)](https://github.com/kaskol10/karpenter-optimizer/releases)\n\n💰 **Cost optimization tool for Karpenter NodePools**. Analyzes Kubernetes cluster usage and provides AI-powered recommendations to reduce AWS EC2 costs while maintaining performance.\n\nKarpenter Optimizer helps you optimize your Karpenter NodePool configurations by analyzing actual cluster usage and providing intelligent, cost-effective instance type recommendations. Get visual before/after comparisons showing cost and resource savings.\n\n## ✨ Features\n\n- 🎯 **Automatic Workload Discovery**: Automatically fetch workloads from your Kubernetes cluster\n- 📊 **Real-time Node Usage**: Visualize actual CPU and memory usage per node with interactive charts\n- 🏗️ **NodePool Analysis**: Analyze existing Karpenter NodePool configurations for accurate before/after comparisons\n- 💡 **AI-Powered Recommendations**: Get intelligent NodePool recommendations optimized for cost and performance using Ollama/LiteLLM/VLLM\n- 💰 **AWS Pricing Integration**: Real-time pricing from AWS Pricing API for accurate cost calculations\n- 🔄 **Spot vs On-Demand Optimization**: Automatically recommends optimal capacity types (spot/on-demand)\n- 📈 **Cost Savings Analysis**: Detailed cost breakdown showing potential savings per NodePool and cluster-wide\n- 🖥️ **Modern Web UI**: React-based interface with real-time updates and progress tracking\n- 🚨 **Disruption Tracking**: Monitor Karpenter node disruptions and identify blocked deletions\n- 📦 **Helm Chart**: Production-ready Helm chart for easy Kubernetes deployment\n- ⚡ **Kubernetes Native**: Uses Kubernetes API directly - no Prometheus required\n\n## 📸 Screenshots\n\n### Cluster Overview\n![Cluster Overview](docs/images/clusterOverview.png)\n\n*View cluster-wide statistics and generate recommendations*\n\n### NodePool Recommendations\n![NodePool Recommendation](docs/images/nodePoolRecommendation.png)\n\n*Detailed NodePool recommendations with before/after comparisons and cost savings*\n\n### Node Usage Visualization\n![Node Usage](docs/images/nodePoolOverallUsage.png)\n\n*Real-time visualization of CPU and memory usage per node with filtering capabilities*\n\n### Pod Location Tracking\n![Pod Location](docs/images/podLocation.png)\n\n*Track pods in nodes with detailed resource usage and filtering by node name or pod name*\n\n### Node Disruption Tracking\n![Node Disruptions](docs/images/nodeDisruption.png)\n\n*Monitor Karpenter node disruptions and identify blocked deletions with PDB visibility*\n\n## Architecture\n\n![Architecture Diagram](docs/images/ArchitectureDiagram.png)\n\nKarpenter Optimizer follows a modern microservices architecture:\n\n- **Backend**: Go-based REST API server with Kubernetes integration\n- **Frontend**: React web application with interactive charts and visualizations\n\nFor detailed architecture documentation, see [docs/architecture.md](docs/architecture.md).\n\n## 🗺️ Roadmap\n\nWe're actively working on improving Karpenter Optimizer. Here's what's coming next:\n\n- Multi-cluster Support - Manage and compare recommendations across multiple Kubernetes clusters\n- Enchanced filtering - Filter recommendations by cost savings, instance types and capacity types\n- Export Recommendations - Export recommendations as YAML manifests for easy application\n- Performance Improvements - Optimize API response times for large clusters\n- Historical Cost Tracking - Track cost trends over time and measure actual savings\n- Machine Learning Predictions - ML-based workload prediction and proactive optimization\n- Cost Allocation - Show costs by namespace, team, or label for better chargeback\n- Scheduled Recommendations - Automated daily/weekly optimization reports via email or Slack, Discord...\n- Policy Engine - Define optimization policies and constraints (e.g., never use spot for production)\n\n### Community-Driven\n\nWe welcome community input! If you have ideas or feature requests, please:\n- Open an issue on [GitHub](https://github.com/kaskol10/karpenter-optimizer/issues)\n- Join our [Discussions](https://github.com/kaskol10/karpenter-optimizer/discussions)\n- Contribute via pull requests\n\n## 🚀 Quick Start\n\n### Prerequisites\n\n- Kubernetes cluster with Karpenter installed\n- kubectl configured with cluster access\n- (Optional) Ollama instance for AI-powered explanations\n- (Optional) IRSA (IAM Roles for Service Accounts) configured for EKS clusters (recommended)\n\n## Quick Install\n\n### Using Helm (Recommended)\n\n```bash\nhelm repo add karpenter-optimizer https://kaskol10.github.io/karpenter-optimizer\nhelm repo update\nhelm install karpenter-optimizer karpenter-optimizer/karpenter-optimizer \\\n  --namespace karpenter-optimizer \\\n  --create-namespace\n```\n\nSee the [Helm chart documentation](charts/karpenter-optimizer/README.md) for detailed configuration options.\n\n### Using Docker\n\n```bash\ndocker run -d \\\n  --name karpenter-optimizer \\\n  -p 8080:8080 \\\n  -v ~/.kube/config:/root/.kube/config:ro \\\n  ghcr.io/kaskol10/karpenter-optimizer:latest\n```\n\n### Local Development\n\n**Backend:**\n\n```bash\n# Install dependencies\ngo mod download\n\n# Run the API server\ngo run ./cmd/api\n```\n\n**Frontend:**\n\n```bash\ncd frontend\nnpm install\nnpm start\n```\n\nThe API will be available at `http://localhost:8080` and the frontend at `http://localhost:3000`\n\n**Environment Variables:**\n- `KUBECONFIG`: Path to kubeconfig file (default: `~/.kube/config`)\n- `KUBE_CONTEXT`: Kubernetes context to use (optional)\n- `PORT`: Port for the API server (default: 8080)\n- `OLLAMA_URL`: URL to Ollama instance for AI explanations (optional)\n- `OLLAMA_MODEL`: Ollama model to use (default: `granite4:latest`)\n\n## 📖 Documentation\n\n- [Quick Start Guide](QUICKSTART.md) - Get started in minutes\n- [Deployment Guide](docs/deployment.md) - Detailed deployment instructions\n- [IRSA Setup Guide](docs/irsa-setup.md) - Configure IAM Roles for Service Accounts (EKS)\n- [Architecture Documentation](docs/architecture.md) - System architecture details\n- [API Reference](docs/api-reference.md) - Complete API documentation\n- [Contributing Guide](CONTRIBUTING.md) - How to contribute\n- [Security Policy](SECURITY.md) - Security reporting\n- [Adopters](ADOPTERS.md) - Organizations using Karpenter Optimizer\n- [Helm Chart Docs](charts/karpenter-optimizer/README.md) - Helm installation guide\n\n### Example Workload JSON\n\n```json\n[\n  {\n    \"name\": \"web-app\",\n    \"namespace\": \"default\",\n    \"cpu\": \"500m\",\n    \"memory\": \"512Mi\",\n    \"gpu\": 0,\n    \"labels\": {}\n  },\n  {\n    \"name\": \"ml-training\",\n    \"namespace\": \"ml\",\n    \"cpu\": \"4\",\n    \"memory\": \"16Gi\",\n    \"gpu\": 1,\n    \"labels\": {\n      \"karpenter.sh/capacity-type\": \"on-demand\"\n    }\n  }\n]\n```\n\n## API Endpoints\n\n### Interactive API Documentation\n\n**Swagger UI**: Access interactive API documentation at `/swagger/index.html`.\n\n**Local Development:**\n```bash\n# Start the API server\ngo run ./cmd/api\n\n# Access Swagger UI at:\n# http://localhost:8080/api/swagger/index.html\n```\n\n**Via Ingress (Production):**\nWhen deployed with ingress enabled:\n- **Frontend**: `https://your-ingress-host/` (root path)\n- **Backend API**: `https://your-ingress-host/api/*` (all API endpoints)\n- **Swagger UI**: `https://your-ingress-host/api/swagger/index.html`\n\nThe ingress routes:\n- `/` → Frontend container (port 80)\n- `/api/*` → Backend container (port 8080)\n\n**Dynamic Host Detection:**\nSwagger automatically detects the request host and scheme (http/https) from ingress headers (`X-Forwarded-Host`, `X-Forwarded-Proto`), so API calls from Swagger UI will work correctly whether accessed directly or through ingress.\n\n### Generate Swagger Documentation\n\n```bash\n# Generate Swagger docs (requires swag CLI: go install github.com/swaggo/swag/cmd/swag@latest)\nmake swagger\n```\n\n### Core Endpoints\n\n- `GET /api/v1/health` - Health check endpoint\n- `GET /api/v1/config` - Get API configuration\n- `POST /api/v1/analyze` - Analyze workloads and get recommendations\n- `GET /api/v1/recommendations` - Get NodePool recommendations based on cluster usage\n- `POST /api/v1/recommendations` - Generate recommendations (alias for GET)\n- `GET /api/v1/recommendations/cluster-summary` - Get recommendations with AI explanations\n- `GET /api/v1/recommendations/cluster-summary/stream` - Get recommendations with SSE progress updates\n- `GET /api/v1/namespaces` - List all Kubernetes namespaces\n- `GET /api/v1/workloads?namespace=\u003cnamespace\u003e` - List workloads in a namespace\n- `GET /api/v1/workloads/:namespace/:name` - Get specific workload details\n- `GET /api/v1/nodepools` - List all Karpenter NodePools\n- `GET /api/v1/nodepools/:name` - Get specific NodePool details\n- `GET /api/v1/nodepools/recommendations` - Get NodePool recommendations\n- `GET /api/v1/nodes` - Get nodes with usage data\n- `GET /api/v1/cluster/summary` - Get cluster-wide statistics\n- `GET /api/v1/disruptions` - Get node disruption information\n- `GET /api/v1/disruptions/recent` - Get recent node deletions\n\nFor complete API documentation with request/response schemas, see the [Swagger UI](http://localhost:8080/swagger/index.html) or generate the docs with `make swagger`.\n\n\n## Recommendation Output\n\nEach recommendation includes:\n\n- **Name**: Nodepool name\n- **Instance Types**: Recommended EC2 instance types\n- **Capacity Type**: Spot or on-demand\n- **Architecture**: amd64 or arm64\n- **Size Range**: Min and max node count\n- **Resource Requirements**: CPU and memory ranges based on actual pod resource requests\n- **Estimated Cost**: Hourly cost estimate\n- **Current State**: Actual NodePool configuration (if found in cluster)\n- **Reasoning**: Explanation of the recommendation\n- **Matched Workloads**: Workloads that match this nodepool\n\n## Visual Comparison Features\n\nThe frontend provides comprehensive before/after comparisons:\n\n- **Cost Comparison**: Current vs recommended costs with savings percentage\n- **Node Comparison**: Current vs recommended node counts with reduction metrics\n- **Annual Savings**: Projected annual cost savings\n- **Per-Nodepool Breakdown**: Detailed charts showing cost and node differences for each nodepool\n- **Interactive Charts**: Bar charts and visualizations using Recharts\n\n## Kubernetes Native Approach\n\nKarpenter Optimizer uses the Kubernetes API directly to analyze your cluster:\n\n1. **Node Usage Calculation**: Calculates CPU and memory usage from scheduled pods\n2. **Real-time Data**: Uses current cluster state - no external metrics required\n3. **Accurate Recommendations**: Bases recommendations on actual resource allocations and node capacity\n\n### How It Works\n\n- Reads pod resource requests directly from Kubernetes API\n- Calculates node usage by summing pod requests on each node\n- Analyzes NodePool configurations and actual node instances\n- Provides recommendations based on actual capacity vs usage\n\n## Kubernetes Integration\n\n\n### NodePool Analysis\n\nThe tool fetches existing Karpenter NodePool configurations:\n\n- **Automatic Discovery**: Lists all NodePools in your cluster\n- **Configuration Parsing**: Extracts instance types, capacity types, limits, and requirements\n- **Before/After Comparison**: Uses actual NodePool configs as the \"before\" state\n- **Cost Calculation**: Estimates costs based on actual instance types\n\n## Development\n\n### Project Structure\n\n```\n.\n├── cmd/\n│   ├── api/            # Backend API server\n│   │   └── main.go\n│   └── cli/            # CLI tool\n│       └── main.go\n├── internal/\n│   ├── api/            # HTTP handlers\n│   ├── config/         # Configuration\n│   ├── kubernetes/     # Kubernetes client\n│   └── recommender/    # Recommendation logic\n├── frontend/           # React frontend\n│   ├── src/\n│   │   ├── components/\n│   │   │   ├── ComparisonView.js\n│   │   │   ├── RecommendationCard.js\n│   │   │   ├── WorkloadForm.js\n│   │   │   └── WorkloadSelector.js\n│   │   └── App.js\n│   └── package.json\n├── examples/           # Example files\n│   └── workloads.json\n└── go.mod\n```\n\n### Building\n\n```bash\n# Build backend\ngo build -o bin/karpenter-optimizer-api ./cmd/api\n\n# Build CLI\ngo build -o bin/karpenter-optimizer ./cmd/cli\n\n# Build frontend\ncd frontend\nnpm run build\n```\n\n### Docker Deployment\n\n```bash\n# Build and run with docker-compose\ndocker-compose up --build\n\n# Or build individually\ndocker build -t karpenter-optimizer-api .\ndocker build -t karpenter-optimizer-frontend ./frontend\n```\n\n## Usage Examples\n\n### Example 1: Analyze Workloads from Cluster\n\n1. Start the backend with Kubernetes access:\n   ```bash\n   KUBECONFIG=~/.kube/config go run ./cmd/api\n   ```\n\n2. Open the frontend at `http://localhost:3000`\n\n3. Select a namespace from the dropdown\n\n4. Check workloads to add them\n\n5. Click \"Analyze Workloads\" to get recommendations\n\n### Example 2: Analyze Cluster Usage\n\n1. Start backend with Kubernetes access:\n   ```bash\n   KUBECONFIG=~/.kube/config go run ./cmd/api\n   ```\n\n2. The recommendations automatically analyze actual pod resource requests and node usage\n\n3. View the comparison charts showing current vs recommended costs\n\n### Example 3: Compare with Existing NodePools\n\n1. Ensure Kubernetes access is configured\n2. The tool automatically fetches existing NodePool configurations\n3. Recommendations show \"before\" (actual NodePools) vs \"after\" (recommended)\n4. View detailed cost and node count comparisons\n\n## 🏗️ Architecture\n\n![Architecture Diagram](docs/images/ArchitectureDiagram.png)\n\nKarpenter Optimizer is built with a modern microservices architecture:\n\n- **Backend**: Go-based REST API server with Kubernetes integration\n- **Frontend**: React web application with interactive charts and visualizations\n- **CLI**: Go CLI tool for command-line usage and CI/CD integration\n- **Helm Chart**: Production-ready Kubernetes deployment\n\nFor detailed architecture documentation, see [docs/architecture.md](docs/architecture.md).\n\n## 🔌 API Endpoints\n\n### Core Endpoints\n\n- `GET /api/v1/health` - Health check\n- `GET /api/v1/cluster/summary` - Cluster-wide statistics\n- `GET /api/v1/nodepools` - List all NodePools\n- `GET /api/v1/nodepools/recommendations` - Get NodePool recommendations\n- `GET /api/v1/recommendations/cluster-summary` - Get cluster-wide recommendations with AI explanations\n- `GET /api/v1/nodes` - List nodes with usage data\n- `GET /api/v1/disruptions` - Get node disruption information\n\nSee the [Swagger UI](http://localhost:8080/swagger/index.html) for complete interactive API documentation with request/response schemas, or generate the docs with `make swagger`.\n\n\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n- 🐛 [Report a Bug](https://github.com/kaskol10/karpenter-optimizer/issues/new?template=bug_report.md)\n- 💡 [Request a Feature](https://github.com/kaskol10/karpenter-optimizer/issues/new?template=feature_request.md)\n- 💬 [Join Discussions](https://github.com/kaskol10/karpenter-optimizer/discussions)\n- 📝 [Submit a Pull Request](https://github.com/kaskol10/karpenter-optimizer/compare)\n\n## 🌟 Adopters\n\nSee [ADOPTERS.md](ADOPTERS.md) for a list of organizations using Karpenter Optimizer. If you're using it, please add your organization via pull request!\n\n## 📄 License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## 🔒 Security\n\nFor security vulnerabilities, please see [SECURITY.md](SECURITY.md).\n\n## 🙏 Acknowledgments\n\nKarpenter Optimizer is heavily influenced by [eks-node-viewer](https://github.com/awslabs/eks-node-viewer), a fantastic tool by AWS Labs that I've been using for years. This project builds on that foundation and adds improvements I needed for my Karpenter workflows:\n\n1. **Easy visualization** - Modern React web UI vs CLI-only\n2. **Track pods in nodes** - Detailed pod-to-node mapping with resource usage\n3. **Clarify node disruptions** - Shows why nodes are blocked (PDBs, constraints)\n4. **Focus on Karpenter** - Built specifically for Karpenter NodePools\n5. **Current cost opportunities** - AI-powered recommendations with actual savings\n\n---\n\n**Made with ❤️ for the Kubernetes community**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaskol10%2Fkarpenter-optimizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaskol10%2Fkarpenter-optimizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaskol10%2Fkarpenter-optimizer/lists"}