karpenter-optimizer

Architecture

Karpenter Optimizer is built with a modern microservices architecture, consisting of a React frontend, Go backend API, and integrations with Kubernetes and AWS services.

High-Level Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend UI   β”‚  React-based web application
β”‚   (Port 80)     β”‚  Served via Nginx
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ HTTP/HTTPS
         β”‚ /api/* β†’ Backend
         β”‚ / β†’ Frontend
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Backend API    β”‚  Go-based REST API
β”‚  (Port 8080)    β”‚  Gin framework
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚         β”‚              β”‚             β”‚
    β–Ό         β–Ό              β–Ό             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚K8s API  β”‚ β”‚AWS      β”‚ β”‚Ollama    β”‚ β”‚Swagger   β”‚
β”‚         β”‚ β”‚Pricing  β”‚ β”‚LLM       β”‚ β”‚Docs      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Component Details

Frontend (React)

Backend (Go)

Kubernetes Integration

AWS Pricing API

Ollama Integration

Data Flow

Recommendation Generation Flow

  1. User Request: Frontend calls /api/v1/recommendations
  2. Fetch NodePools: Backend queries Kubernetes for NodePools
  3. Fetch Nodes: Backend queries Kubernetes for nodes in each NodePool
  4. Calculate Usage: Backend calculates CPU/Memory usage from pod requests
  5. Fetch Pricing: Backend queries AWS Pricing API for instance costs
  6. Generate Recommendations: Backend runs recommendation algorithm
  7. Enhance with AI (optional): Backend calls Ollama for explanations
  8. Return Results: Backend returns recommendations to frontend
  9. Display: Frontend renders recommendations with charts

Cost Calculation Flow

  1. Current Cost: Sum of (node count Γ— instance price Γ— capacity type multiplier)
  2. Recommended Cost: Calculate optimal instance types and node count
  3. Compare: Show cost savings percentage and dollar amount
  4. Validate: Skip recommendations that increase cost by >10%

Deployment Architecture

Sidecar Pattern (Default)

Separate Deployments (Optional)

Security Considerations

Scalability

Monitoring

Future Enhancements

For more details, see: