💰 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
- 📈 Cluster Trends: CPU, memory, GPU-memory and estimated-cost trend sparklines in the Cluster Overview (1h/6h/24h) from a background sampler; per-node age badges in the Topology view
- 📊 Real-time Node Usage: Visualize actual CPU and memory usage per node with interactive charts
- 🗺️ Topology View: Semantic zoom from a Cluster map (every node a tile, grouped by NodePool and zone, coloured by a lens: requests, capacity type, age, cost, serving health, disruption) to a NodePool, a node and a single GPU, each level with its own URL. With metrics-server or Prometheus it shows requested vs actually used (idle requests hatched, a Usage lens), flags workloads whose replicas all sit on one node or zone, and gives each node an actions menu (copy kubectl commands, open pod logs). A drain simulator shows where each pod on the chosen nodes would land, what would not fit and the monthly saving, and a placement planner answers "where can 2 replicas of a 40 GiB model go?" (both approximate and read-only). Time travel replays the cluster at any moment of the last day (
?time=) or compares now with then (?compare=): launched nodes ringed green, removed ones drawn as dashed ghosts with Karpenter's reason, moved pods listed, all on a timeline marked with every launch, termination and move. Bird’s-eye view of pods on nodes with segment sizes by CPU or memory requests (grouped by NodePool); GPU nodes additionally get a dedicated GPU requests section (memory-based under HAMi), with each physical GPU drawn as a memory tank (pods stacked, free on top) and a per-node fragmentation line ("66 GiB free, largest single gap 38 GiB"). A Will it fit? box takes a size and highlights every GPU with that much free on one card (?fit=40GiB, shareable), and pod names are click-to-copy (namespace/name) - 🏗️ 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 Bedrock
- 💰 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
- 🔔 Alerting Engine: Opt-in condition monitoring (cost spike, blocked disruptions, serving under pressure, gateway errors, serving pod offline) with a pending→firing→cleared state machine and fan-out to ntfy, Discord, Slack, or a generic JSON webhook — all channels SSRF-validated (public http(s) only, no redirects, resolve-then-pin). Configure via the UI's Alerts settings or
GET/PUT /api/v1/alerts/config; channel URLs are treated as credentials (masked in the API, stored in a secret/state file) - 📡 Prometheus
/metricsExporter: Opt-in (METRICS_ENABLED/metrics.enabled) text-0.0.4 endpoint exposing cluster, per-NodePool, serving-pod, LiteLLM gateway, and disruption gauges (karpenter_optimizer_*) — refreshed by the existing samplers, so a scrape makes zero extra Kubernetes or AWS Pricing API calls. Works with the chart's optional ServiceMonitor - 💾 Durable Serving History: per-pod serving samples persisted to Postgres/CNPG (same instance as the gateway cost history) when
SERVING_HISTORY_DSN(orGATEWAY_HISTORY_DB_*) is set — the Serving tab's trend window gains 7d alongside 1h/6h/24h, surviving restarts; without a DSN it stays in-memory as before - 🌗 Dark/Light Theme: sun/moon toggle in the header (persisted, defaults to system preference, no flash on first paint) — every view, chart, and table is themed through semantic tokens
- 🖼️ Polished UI States: consistent empty-state cards with retry actions, loading skeletons that avoid layout shift, and error banners with retry across every tab
- ⌘ Command palette (⌘K / Ctrl+K): jump to any page, node, pod, GPU or model by typing part of its name, or type
drain <node>,logs <pod>orfit 40GiB 3. The header also shows one status line: cluster connection, Karpenter, last refresh and firing alerts - 🧭 Three areas: Cluster (Overview, Nodes, Topology, Disruptions), Inference (Serving, Gateway) and Optimize (Recommendations, Workloads). Every page has its own path (
/cluster/topology,/inference/gateway) and an area remembers the page you last had open in it. Old?tab=links still work: they redirect to the new paths - 🔍 Cluster-Wide Log Explorer: a Logs drawer over any page (header button, or a pod's Logs link in Topology and Serving,
?logs=namespace/name). Pick any pod in the cluster and read/analyze its logs — container selection, tail/since/previous-container controls, search with match highlighting, and AI (or built-in heuristic) analysis of error lines with actionable recommendations. Karpenter's structured error logs get the dedicated Karpenter analysis; everything else is analyzed generically - 🎮 GPU Allocation Visualization: See GPU count, memory, and allocation per node, pod, and cluster (allocation-based, no DCGM/Prometheus). GPU count/memory read from node labels (
nvidia.com/gpu.count,nvidia.com/gpu.memory); HAMi/KAI memory partitioning aware (nvidia.com/gpumem+hami.io/vgpu-devices-allocated) — when HAMi is detected, GPU usage is reported as memory % in use plus a GPU pod count (fractional-GPU friendly) - 🤖 LLM Serving Health: A "Serving" tab probes in-cluster vLLM/sglang pods to show inference health — model, KV cache %, running/waiting, TTFT (mean/p95), end-to-end latency (mean/p95), preemptions, token throughput, and request rate. Each card shows a one-glance status (OK/Busy/Slow/Under pressure) with fix hints, where the model runs (node, instance type, GPU model, and the specific GPU card UUID on HAMi/KAI clusters), one row per model with a Needs attention triage list on top, an estimated cost per 1M tokens per model (its replicas' share of their nodes' GPUs at the node's price) compared with what a hosted API charges for the same model (OpenRouter's public price list, fetched daily; hidden without internet egress), an estimated traffic headroom before KV-cache pressure (fitted from serving history), and collapsible per-metric trend sparklines (1h/6h/24h) with a "last issue seen" marker for historical traceability
- 🚦 LiteLLM AI-Gateway Health: when LiteLLM proxy pods are detected, the Inference → Gateway page shows a LiteLLM Gateway card — fleet-wide in-flight requests, admission queue, 503 rejections, error rate, E2E p95, gateway overhead p95 (isolates gateway cost from model latency), requests/s, cumulative spend, and a breakdown table you can split by App / API key / Team (
metadata_trace_name/api_key_alias/team_alias, default App) — per calling dimension: total tokens split input/output, requests, tokens/s, spend; the Models view shows per-model latency + spend with expandable rows revealing which apps/keys/teams use each model. The Flow view draws it as a Sankey: apps (or API keys, or teams) on the left, models on the right, bands sized by tokens or spend, with the largest flows listed underneath. A Usage by day dashboard tracks per-day spend and token usage (UTC, 00:00–23:59) over 7/14/30 days — stacked bars by the selected split dimension plus a per-day table with the top consumer. Below it, Team usage reads LiteLLM's metrics from Prometheus (PROMETHEUS_URL): pick a team, model alias, API key and range (this month, 24 h, 7 or 30 days) to see spend against the team budget, requests, error rate and 429s, spend per day by model, tokens per day (input, cached, output), one row per API key, time to first token and fallback share per model, and the deployments LiteLLM routes to with their state next to the vLLM/sglang replicas serving them. A routing map draws who calls which alias, which deployment serves it and where that runs (vLLM pods in this cluster, another host, or an external API); click any team, key, alias, deployment or host to light up its paths, see its split, and filter the card by it. Outages still receiving traffic, fallbacks, duplicate deployments, throttled teams and budgets nearly spent are flagged on the map. On the Serving page, a model reached through LiteLLM shows the teams and apps calling it, its request rate and error rate. SetLITELLM_METRICS_API_KEYif the proxy's/metricsrequires auth (LiteLLM ≥ v1.85.0); a 401/403 shows an actionable hint instead of failing - 🏢 On-Prem / No-Karpenter Mode: Gracefully degrades when Karpenter is absent — cluster-wide stats, GPU view, and "n/a" costs instead of errors
- ⚡ Fleet Power Estimation: A coarse estimated power draw per instance family (e.g.
p4d~3.3 kW,p5~10.2 kW) shown as an "Est. Power" tile in the Cluster Overview (clearly an estimate, with node coverage) - 📦 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
Auto-refreshes every 60s (toggleable). Shows how much a stuck node is still costing ($X/hr, spot-aware) plus a cluster-level "still billed" summary, and lists recently-terminated nodes from the disruptions/recent endpoint. Node/PDB/pod names are click-to-copy.
Pod-on-node topology with per-GPU placement lanes under HAMi — each physical card gets its own memory lane
Inference health per vLLM/sglang pod (status badge, KV cache, TTFT/E2E, throughput) plus the LiteLLM Gateway card with spend/token breakdowns and a usage-by-day dashboard (1h/6h/24h/7d trends)
The same Serving view in dark mode — the theme toggle (header) is persisted and defaults to your system preference
Opt-in alerting: cost spikes, blocked disruptions, serving under pressure, gateway errors, and offline pods → ntfy / Discord / Slack / webhook (SSRF-validated, URLs masked)
Karpenter Optimizer is a two-tier application:
- 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
- Enhanced 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 forecasting and proactive (predictive) 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)
- Frontend and backend images from the same release. The Helm chart does this; mixing an older backend with a newer frontend is not supported (Topology reports it instead of guessing)
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.
To enable durable LiteLLM gateway cost history (per-day spend/tokens that survive restarts), set database.enabled=true — this provisions a small CloudNativePG (CNPG) PostgresCluster. The CNPG operator must already be installed in the cluster:
helm install karpenter-optimizer karpenter-optimizer/karpenter-optimizer \
--namespace karpenter-optimizer \
--create-namespace \
--set database.enabled=true \
--set database.cluster.retentionHours=720Without it, cost history is kept in-memory and resets when the optimizer pod restarts.
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)LLM_PROVIDER:ollama,litellmorbedrock(auto-detected fromLLM_URL, exceptbedrockwhich must be set explicitly)LLM_URL/LLM_MODEL/LLM_API_KEY: generic LLM configuration superseding theOLLAMA_*variablesLLM_AWS_REGION: AWS region for Bedrock, if different from the default AWS region (optional; thebedrockprovider signs Converse API requests with the AWS default credential chain — e.g. IRSA on EKS — so it needs no URL or API key, justbedrock:InvokeModelpermissions andLLM_MODELset to a model or inference profile ID). The standard AWS SDK endpoint variables (AWS_ENDPOINT_URL,AWS_ENDPOINT_URL_BEDROCK_RUNTIME) are honored for VPC endpoints or gateways; setAWS_IGNORE_CONFIGURED_ENDPOINT_URLS=truein hardened deployments to pin the SDK to the regional AWS endpoints.LLM_MAX_TOKENS: response token cap for Bedrock requests (optional; unset = the model's default maximum) — set it to bound the worst-case cost per requestLITELLM_METRICS_API_KEY: Bearer token for the LiteLLM proxy/metricsendpoint (optional; required by LiteLLM ≥ v1.85.0). When the gateway's metrics endpoint answers 401/403, the Serving tab shows an actionable hint pointing at this variableGATEWAY_HISTORY_DSN: Postgres DSN for durable LiteLLM gateway cost history (e.g. a CNPG cluster; optional). Empty = an in-memory history that resets on restart. Alternatively setGATEWAY_HISTORY_DB_HOST/PORT/USER/NAME+GATEWAY_HISTORY_DB_PASSWORDand the DSN is composed for you (the Helm chart uses this so the password comes from the CNPG credentials secret)GATEWAY_HISTORY_RETENTION_HOURS: how long to keep gateway cost history (default: 720 = 30 days)SERVING_HISTORY_DSN: Postgres DSN for durable serving-history samples (optional). Empty = in-memory only (trend windows capped atHISTORY_WINDOW_HOURS). When set, the Serving tab's trend selector gains a 7d option and history survives restarts. Reuses the gateway'sGATEWAY_HISTORY_DB_*parts when no explicit DSN is set, so both histories can share one CNPG instanceSERVING_HISTORY_RETENTION_HOURS: how long to keep durable serving samples (default: 168 = 7 days)PLACEMENT_HISTORY_HOURS: how much placement history the Topology time travel keeps (default 24, max 72,0turns the sampler off). In memory, and also in Postgres when a database is configured, so it survives restartsPLACEMENT_HISTORY_DSN: Postgres for the placement history. Optional: without it the serving-history DSN is used, then the gateway's (the chart'sdatabase.enabled: truecovers all three)PLACEMENT_HISTORY_INTERVAL_SECS: how often placement is sampled (default 120, minimum 30). Each sample lists every node and pod once, like opening the Topology tabPROMETHEUS_URL: in-cluster Prometheus to read actual usage from (optional, display only). The Topology tab then shows each pod's p95 CPU and memory over 24h next to its request (idle requests hatched) and GPU memory in use from the DCGM exporter. Without it, live usage comes from metrics-server when installed. It also feeds the Gateway team dashboard from the LiteLLM metrics that Prometheus scrapes. Chart valueusage.prometheusUrl. Grafana Mimir works too: point it at the query-frontend with the/prometheusprefix (http://mimir-query-frontend.mimir.svc:8080/prometheus) and set the tenant belowLITELLM_CONFIGMAP_NAMESPACE/LITELLM_CONFIGMAP_NAME: the ConfigMap holding the LiteLLM proxyconfig.yaml, for the Gateway page's fallback map (optional;LITELLM_CONFIGMAP_KEY, defaultconfig.yaml). Only the routing is read: model groups, aliases, fallbacks and router settings. Chart valueslitellmConfig.namespace/litellmConfig.configMapName/litellmConfig.key; the chart adds a Role in that namespace allowinggeton that ConfigMap onlyPROMETHEUS_TENANT: sent as theX-Scope-OrgIDheader on every query toPROMETHEUS_URL, for multi-tenant APIs such as Grafana Mimir (optional). Chart valueusage.prometheusTenantMETRICS_ENABLED: enable the Prometheus/metricsexporter (true/1, default off →/metrics404s). Chart value:metrics.enabled- Alerting is configured at runtime via the UI or
GET/PUT /api/v1/alerts/config(persisted toalerts.stateFile), or chart valuesalerts.enabled/alerts.urls(comma-separatedtype=urlchannel entries — keep secrets out of git in prod)
Pricing note: Cost estimates use live AWS Pricing API results when available. Instance-type discovery filters AWS Pricing index entries to the configured region and uses AWS processorArchitecture metadata to distinguish ARM from x86 types. Dated fallback snapshots queried 2026-10-19 are available for selected us-east-1 USD and China-region CNY instance types; they may become stale and should be refreshed periodically. Snapshots are only used when pricing cannot be queried, and not when the Pricing API explicitly returns no product. The US snapshot is not reused for other commercial regions. Spot pricing is an estimate based on a fixed discount from on-demand pricing, not a live Spot market quote.
- 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 /api/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/topology- Get nodes with scheduled pods and per-pod requests (topology view)GET /api/v1/serving/gateway/routing?range=7d- LiteLLM routing and fallbacks: model groups, aliases, the fallback chain of each group, retry and cooldown settings and the issues found, read from the proxy's ConfigMap (LITELLM_CONFIGMAP_*), next to the fallbacks taken and why (from Prometheus, when set). API keys and prices are never returnedGET /api/v1/serving/gateway/dashboard?team=&model=&key=&range=month- LiteLLM team dashboard (spend and budget, requests and errors, spend and tokens per day, one row per API key, latency per model), read from Prometheus (PROMETHEUS_URL)GET /api/v1/alerts/status- Whether alerting is on and which conditions are firing ({enabled, firing: [{id, title, severity, since}]}), for the header status stripGET /api/v1/topology/history?at=<unix|RFC3339>- The topology as recorded at the latest placement sample at or beforeat(same node shape; cost at today's prices, no usage)GET /api/v1/topology/events?since=6h- Node launches, terminations (with the Karpenter disruption reason, read when the node left, and how it went:lifecycle[]of disrupted → drain failed ×N → instance terminating → removed, plusgoneAt, when the Node object was deleted) and pod moves between placement samples, plus the recorded rangeGET /api/v1/cluster/summary- Get cluster-wide statisticsGET /api/v1/serving- Inference health for detected vLLM/sglang serving pods (model, KV cache %, running/waiting, TTFT, E2E latency, preemptions, throughput split into input/output, request rate, node/GPU placement, GPU neighbours, estimated hourlycostper replica, and the hostedhostedPricefor the same model when known)GET /api/v1/serving/history?window=6h- Per-pod serving metric trends (sampled every 60s) + last time each pod was unhealthy; in-memory by default, durable Postgres/CNPG whenSERVING_HISTORY_DSNis set (adds a7dwindow)GET /api/v1/serving/gateway- LiteLLM AI-gateway health: fleet-wide in-flight/queue/503/error/latency (E2E + overhead p95)/spend + usage breakdowns split by app / API key / team (metadata_trace_name/api_key_alias/team_alias), each with per-model detail (tokens split input/output);nullwhen no LiteLLM proxy is detectedGET /api/v1/serving/gateway/history?split=app&window=14d- Per-day LiteLLM gateway cost & token usage by split dimension (or fleet total); in-memory by default, durable CNPG Postgres when enabledGET /api/v1/disruptions- Get node disruption informationGET /api/v1/disruptions/recent- Get recent node deletionsGET /api/v1/pods?namespace=- List pods as compact summaries (status, readiness, containers, restarts, Karpenter flag) for the Log Explorer pickerGET /api/v1/pods/logs?namespace=&pod=&container=&tailLines=&sinceSeconds=&previous=- Container logs for any pod (no Karpenter gate)POST /api/v1/logs/analyze- Analyze a Karpenter JSON error line or a block of generic container logs (LLM when configured, built-in heuristic classifier otherwise)POST /api/v1/karpenter/logs/analyze- Analyze Karpenter error logs (Karpenter-JSON only; the Karpenter pod log gate is unchanged)GET /api/v1/alerts/config- Alerting config (channel URLs masked); 503 when alerts are not configuredPUT /api/v1/alerts/config- Replace the alerting config (conditions, reminder interval, channels); masked URLs are preservedPOST /api/v1/alerts/test- Send a test alert through every configured channelGET /metrics- Prometheus text-0.0.4 gauges (only whenMETRICS_ENABLED=true; 404 otherwise)
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/
│ ├── agent/ # Cost-optimization agent
│ ├── api/ # HTTP handlers
│ ├── awspricing/ # AWS Pricing API client
│ ├── config/ # Configuration
│ ├── kubernetes/ # Kubernetes client
│ ├── ollama/ # LLM client (Ollama/LiteLLM/VLLM/Bedrock)
│ └── recommender/ # Recommendation logic
├── frontend/ # React frontend
│ ├── src/
│ │ ├── components/
│ │ │ ├── AgentRecommendations.jsx
│ │ │ ├── DisruptionTracker.jsx
│ │ │ ├── GlobalClusterSummary.jsx
│ │ │ ├── LogExplorer.jsx
│ │ │ ├── NodePoolCard.jsx
│ │ │ ├── NodeUsageView.jsx
│ │ │ ├── WorkloadUsageView.jsx
│ │ │ ├── serving/ # Serving tab (ServingHealth, ServingCard, GatewayCard, ...)
│ │ │ └── topology/ # Topology tab (TopologyView, NodeCard, GPULaneBar, ...)
│ │ ├── hooks/ # usePolling, useUrlParam
│ │ ├── lib/ # api, pollingClock, servingStatus, servingPlacement, ...
│ │ └── App.jsx
│ └── 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 -
On the Overview tab, click "Generate Recommendations"
-
Review the per-NodePool recommendations and cluster-wide cost summary
-
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
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.
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









