π° Cost optimization tool for Karpenter NodePools. Analyzes Kubernetes cluster usage and provides AI-powered recommendations to reduce AWS EC2 costs while maintaining performance.
Karpenter 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.
- π― Automatic Workload Discovery: Automatically fetch workloads from your Kubernetes cluster
- π Real-time Node Usage: Visualize actual CPU and memory usage per node with interactive charts
- ποΈ NodePool Analysis: Analyze existing Karpenter NodePool configurations for accurate before/after comparisons
- π‘ AI-Powered Recommendations: Get intelligent NodePool recommendations optimized for cost and performance using Ollama/LiteLLM/VLLM
- π° AWS Pricing Integration: Real-time pricing from AWS Pricing API for accurate cost calculations
- π Spot vs On-Demand Optimization: Automatically recommends optimal capacity types (spot/on-demand)
- π Cost Savings Analysis: Detailed cost breakdown showing potential savings per NodePool and cluster-wide
- π₯οΈ Modern Web UI: React-based interface with real-time updates and progress tracking
- π¨ Disruption Tracking: Monitor Karpenter node disruptions and identify blocked deletions
- π Karpenter Log Analyzer: Analyze Karpenter error logs with AI-powered explanations and actionable recommendations
- π¦ Helm Chart: Production-ready Helm chart for easy Kubernetes deployment
- β‘ Kubernetes Native: Uses Kubernetes API directly - no Prometheus required
View cluster-wide statistics and generate recommendations
Detailed NodePool recommendations with before/after comparisons and cost savings
Real-time visualization of CPU and memory usage per node with filtering capabilities
Track pods in nodes with detailed resource usage and filtering by node name or pod name
Monitor Karpenter node disruptions and identify blocked deletions with PDB visibility
Karpenter Optimizer follows a modern microservices architecture:
- Backend: Go-based REST API server with Kubernetes integration
- Frontend: React web application with interactive charts and visualizations
For detailed architecture documentation, see docs/architecture.md.
We're actively working on improving Karpenter Optimizer. Here's what's coming next:
- Multi-cluster Support - Manage and compare recommendations across multiple Kubernetes clusters
- Enchanced filtering - Filter recommendations by cost savings, instance types and capacity types
- Export Recommendations - Export recommendations as YAML manifests for easy application
- Performance Improvements - Optimize API response times for large clusters
- Historical Cost Tracking - Track cost trends over time and measure actual savings
- Machine Learning Predictions - ML-based workload prediction and proactive optimization
- Cost Allocation - Show costs by namespace, team, or label for better chargeback
- Scheduled Recommendations - Automated daily/weekly optimization reports via email or Slack, Discord...
- Policy Engine - Define optimization policies and constraints (e.g., never use spot for production)
We welcome community input! If you have ideas or feature requests, please:
- Open an issue on GitHub
- Join our Discussions
- Contribute via pull requests
- Kubernetes cluster with Karpenter installed
- kubectl configured with cluster access
- (Optional) Ollama instance for AI-powered explanations
- (Optional) IRSA (IAM Roles for Service Accounts) configured for EKS clusters (recommended)
helm repo add karpenter-optimizer https://kaskol10.github.io/karpenter-optimizer
helm repo update
helm install karpenter-optimizer karpenter-optimizer/karpenter-optimizer \
--namespace karpenter-optimizer \
--create-namespaceSee the Helm chart documentation for detailed configuration options.
docker run -d \
--name karpenter-optimizer \
-p 8080:8080 \
-v ~/.kube/config:/root/.kube/config:ro \
ghcr.io/kaskol10/karpenter-optimizer:latestBackend:
# Install dependencies
go mod download
# Run the API server
go run ./cmd/apiFrontend:
cd frontend
npm install
npm startThe API will be available at http://localhost:8080 and the frontend at http://localhost:3000
Environment Variables:
KUBECONFIG: Path to kubeconfig file (default:~/.kube/config)KUBE_CONTEXT: Kubernetes context to use (optional)PORT: Port for the API server (default: 8080)OLLAMA_URL: URL to Ollama instance for AI explanations (optional)OLLAMA_MODEL: Ollama model to use (default:granite4:latest)
- Quick Start Guide - Get started in minutes
- Deployment Guide - Detailed deployment instructions
- IRSA Setup Guide - Configure IAM Roles for Service Accounts (EKS)
- Architecture Documentation - System architecture details
- API Reference - Complete API documentation
- Contributing Guide - How to contribute
- Security Policy - Security reporting
- Adopters - Organizations using Karpenter Optimizer
- Helm Chart Docs - Helm installation guide
[
{
"name": "web-app",
"namespace": "default",
"cpu": "500m",
"memory": "512Mi",
"gpu": 0,
"labels": {}
},
{
"name": "ml-training",
"namespace": "ml",
"cpu": "4",
"memory": "16Gi",
"gpu": 1,
"labels": {
"karpenter.sh/capacity-type": "on-demand"
}
}
]Swagger UI: Access interactive API documentation at /swagger/index.html.
Local Development:
# Start the API server
go run ./cmd/api
# Access Swagger UI at:
# http://localhost:8080/api/swagger/index.htmlVia Ingress (Production): When deployed with ingress enabled:
- Frontend:
https://your-ingress-host/(root path) - Backend API:
https://your-ingress-host/api/*(all API endpoints) - Swagger UI:
https://your-ingress-host/api/swagger/index.html
The ingress routes:
/β Frontend container (port 80)/api/*β Backend container (port 8080)
Dynamic Host Detection:
Swagger 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.
# Generate Swagger docs (requires swag CLI: go install github.com/swaggo/swag/cmd/swag@latest)
make swaggerGET /api/v1/health- Health check endpointGET /api/v1/config- Get API configurationPOST /api/v1/analyze- Analyze workloads and get recommendationsGET /api/v1/recommendations- Get NodePool recommendations based on cluster usagePOST /api/v1/recommendations- Generate recommendations (alias for GET)GET /api/v1/recommendations/cluster-summary- Get recommendations with AI explanationsGET /api/v1/recommendations/cluster-summary/stream- Get recommendations with SSE progress updatesGET /api/v1/namespaces- List all Kubernetes namespacesGET /api/v1/workloads?namespace=<namespace>- List workloads in a namespaceGET /api/v1/workloads/:namespace/:name- Get specific workload detailsGET /api/v1/nodepools- List all Karpenter NodePoolsGET /api/v1/nodepools/:name- Get specific NodePool detailsGET /api/v1/nodepools/recommendations- Get NodePool recommendationsGET /api/v1/nodes- Get nodes with usage dataGET /api/v1/cluster/summary- Get cluster-wide statisticsGET /api/v1/disruptions- Get node disruption informationGET /api/v1/disruptions/recent- Get recent node deletions
For complete API documentation with request/response schemas, see the Swagger UI or generate the docs with make swagger.
Each recommendation includes:
- Name: Nodepool name
- Instance Types: Recommended EC2 instance types
- Capacity Type: Spot or on-demand
- Architecture: amd64 or arm64
- Size Range: Min and max node count
- Resource Requirements: CPU and memory ranges based on actual pod resource requests
- Estimated Cost: Hourly cost estimate
- Current State: Actual NodePool configuration (if found in cluster)
- Reasoning: Explanation of the recommendation
- Matched Workloads: Workloads that match this nodepool
The frontend provides comprehensive before/after comparisons:
- Cost Comparison: Current vs recommended costs with savings percentage
- Node Comparison: Current vs recommended node counts with reduction metrics
- Annual Savings: Projected annual cost savings
- Per-Nodepool Breakdown: Detailed charts showing cost and node differences for each nodepool
- Interactive Charts: Bar charts and visualizations using Recharts
Karpenter Optimizer uses the Kubernetes API directly to analyze your cluster:
- Node Usage Calculation: Calculates CPU and memory usage from scheduled pods
- Real-time Data: Uses current cluster state - no external metrics required
- Accurate Recommendations: Bases recommendations on actual resource allocations and node capacity
- Reads pod resource requests directly from Kubernetes API
- Calculates node usage by summing pod requests on each node
- Analyzes NodePool configurations and actual node instances
- Provides recommendations based on actual capacity vs usage
The tool fetches existing Karpenter NodePool configurations:
- Automatic Discovery: Lists all NodePools in your cluster
- Configuration Parsing: Extracts instance types, capacity types, limits, and requirements
- Before/After Comparison: Uses actual NodePool configs as the "before" state
- Cost Calculation: Estimates costs based on actual instance types
.
βββ cmd/
β βββ api/ # Backend API server
β β βββ main.go
β βββ cli/ # CLI tool
β βββ main.go
βββ internal/
β βββ api/ # HTTP handlers
β βββ config/ # Configuration
β βββ kubernetes/ # Kubernetes client
β βββ recommender/ # Recommendation logic
βββ frontend/ # React frontend
β βββ src/
β β βββ components/
β β β βββ ComparisonView.js
β β β βββ RecommendationCard.js
β β β βββ WorkloadForm.js
β β β βββ WorkloadSelector.js
β β βββ App.js
β βββ package.json
βββ examples/ # Example files
β βββ workloads.json
βββ go.mod
# Build backend
go build -o bin/karpenter-optimizer-api ./cmd/api
# Build CLI
go build -o bin/karpenter-optimizer ./cmd/cli
# Build frontend
cd frontend
npm run build# Build and run with docker-compose
docker-compose up --build
# Or build individually
docker build -t karpenter-optimizer-api .
docker build -t karpenter-optimizer-frontend ./frontend-
Start the backend with Kubernetes access:
KUBECONFIG=~/.kube/config go run ./cmd/api -
Open the frontend at
http://localhost:3000 -
Select a namespace from the dropdown
-
Check workloads to add them
-
Click "Analyze Workloads" to get recommendations
-
Start backend with Kubernetes access:
KUBECONFIG=~/.kube/config go run ./cmd/api -
The recommendations automatically analyze actual pod resource requests and node usage
-
View the comparison charts showing current vs recommended costs
- Ensure Kubernetes access is configured
- The tool automatically fetches existing NodePool configurations
- Recommendations show "before" (actual NodePools) vs "after" (recommended)
- View detailed cost and node count comparisons
Karpenter Optimizer is built with a modern microservices architecture:
- Backend: Go-based REST API server with Kubernetes integration
- Frontend: React web application with interactive charts and visualizations
- CLI: Go CLI tool for command-line usage and CI/CD integration
- Helm Chart: Production-ready Kubernetes deployment
For detailed architecture documentation, see docs/architecture.md.
GET /api/v1/health- Health checkGET /api/v1/cluster/summary- Cluster-wide statisticsGET /api/v1/nodepools- List all NodePoolsGET /api/v1/nodepools/recommendations- Get NodePool recommendationsGET /api/v1/recommendations/cluster-summary- Get cluster-wide recommendations with AI explanationsGET /api/v1/nodes- List nodes with usage dataGET /api/v1/disruptions- Get node disruption information
See the Swagger UI for complete interactive API documentation with request/response schemas, or generate the docs with make swagger.
We welcome contributions! Please see our Contributing Guide for details.
- π Report a Bug
- π‘ Request a Feature
- π¬ Join Discussions
- π Submit a Pull Request
See ADOPTERS.md for a list of organizations using Karpenter Optimizer. If you're using it, please add your organization via pull request!
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
For security vulnerabilities, please see SECURITY.md.
Karpenter Optimizer is heavily influenced by 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:
- Easy visualization - Modern React web UI vs CLI-only
- Track pods in nodes - Detailed pod-to-node mapping with resource usage
- Clarify node disruptions - Shows why nodes are blocked (PDBs, constraints)
- Focus on Karpenter - Built specifically for Karpenter NodePools
- Current cost opportunities - AI-powered recommendations with actual savings
Made with β€οΈ for the Kubernetes community





