feat: use Karpenter for CPU node autoscaling (industry standard)#40
Open
wdvr wants to merge 1 commit into
Open
feat: use Karpenter for CPU node autoscaling (industry standard)#40wdvr wants to merge 1 commit into
wdvr wants to merge 1 commit into
Conversation
…ambda approach) Replace fixed 60 CPU nodes with Karpenter-managed dynamic scaling (0-30 nodes per type). Karpenter provisions nodes on-demand when pods are pending (~60s) and consolidates when idle (60s). This is the industry-standard approach for EKS autoscaling. Key changes: - main.tf: CPU types set to karpenter_managed=true, instance_count=0 - eks.tf: Filter Karpenter types from ASG creation - karpenter.tf: Full Karpenter setup (IAM, SQS, Helm, NodePools, EC2NodeClasses) - availability_updater Lambda: Handle Karpenter types (query K8s directly, not ASG) - CLI: Show "0 / 90" scalable capacity and "~1min (scaling up)" wait time Architecture: - Karpenter controller runs on management CPU nodes (c5.4xlarge ASG, 2 nodes) - NodePool per architecture (cpu-x86, cpu-arm) with 30-node CPU limits - EC2NodeClass defines AL2023, 500GB gp3, security groups, subnets - SQS queue for spot/interruption handling (EventBridge → SQS → Karpenter) Benefits vs custom Lambda approach: - Faster scale-up (~60s vs ~3min ASG polling) - Event-driven (reacts to pending pods immediately) - Built-in consolidation with pod disruption budgets - Less custom code to maintain (~100 lines removed) - Industry standard for EKS Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace fixed 60 CPU nodes with Karpenter-managed dynamic scaling (0-30 nodes per type). This is an alternative to PR #37's custom Lambda approach, using the industry-standard EKS autoscaling solution.
Comparison: Karpenter vs Custom Lambda
Architecture
Karpenter controller:
NodePools (2):
cpu-x86: c7i.8xlarge (prod) / c7i.4xlarge (default), max 30 nodescpu-arm: c7g.8xlarge (prod) / c7g.4xlarge (default), max 30 nodesInterruption handling:
Files changed
main.tfkarpenter_managed=true,instance_count=0eks.tfif !try(gpu_config.karpenter_managed, false))karpenter.tfavailability_updater/index.pycli.py+reservations.py"0 / 90"scalable capacity and"~1min (scaling up)"Test plan
terraform plan— CPU ASGs removed, Karpenter resources createdtf apply: 0 CPU nodes initially, management nodes running Karpentergpu-dev availshows0 / 90and~1min (scaling up)for CPU typeskarpenter_managedfield)Why Karpenter?
This is the AWS-recommended approach for EKS autoscaling. It's:
The tradeoff is a bigger infrastructure change (Karpenter install, new IAM roles, EventBridge setup) vs the quick Lambda approach in PR #37. But for production, Karpenter is the right choice.