π° 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.
View cluster-wide statistics and generate recommendations
See potential cost savings across your entire cluster
Detailed NodePool recommendations with before/after comparisons
Get intelligent explanations for each recommendation
Real-time visualization of CPU and memory usage per node
Monitor Karpenter node disruptions and identify blocked deletions
Configure Kubernetes, Ollama, and AWS Pricing API settings

Karpenter Optimizer follows a modern microservices architecture:
For detailed architecture documentation, see docs/architecture.md.
Weβre actively working on improving Karpenter Optimizer. Hereβs whatβs coming next:
We welcome community input! If you have ideas or feature requests, please:
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-namespace
See 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:latest
Backend:
# Install dependencies
go mod download
# Run the API server
go run ./cmd/api
Frontend:
cd frontend
npm install
npm start
The 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)[
{
"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.html
Via Ingress (Production): When deployed with ingress enabled:
https://your-ingress-host/ (root path)https://your-ingress-host/api/* (all API endpoints)https://your-ingress-host/api/swagger/index.htmlThe 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 swagger
GET /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 deletionsFor complete API documentation with request/response schemas, see the Swagger UI or generate the docs with make swagger.
Each recommendation includes:
The frontend provides comprehensive before/after comparisons:
Karpenter Optimizer uses the Kubernetes API directly to analyze your cluster:
The tool fetches existing Karpenter NodePool configurations:
.
βββ 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
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
KUBECONFIG=~/.kube/config go run ./cmd/api
The recommendations automatically analyze actual pod resource requests and node usage

Karpenter Optimizer is built with a modern microservices architecture:
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 informationSee 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.
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.
Made with β€οΈ for the Kubernetes community