---
name: "karpenter-just-in-time-nodepool"
description: "Provision right-sized compute nodes in under 45 seconds directly from un-schedulable pod requests."
metadata:
  author: "AWS"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "setup karpenter nodepool"
  - "configure ec2nodeclass karpenter"
  - "consolidate k8s nodes karpenter"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Karpenter Just-In-Time Kubernetes Node Autoscaling

Configures AWS Karpenter: declaring NodePool and EC2NodeClass manifests, selecting spot vs on-demand instances, instance family consolidation policies (WhenEmptyOrUnderutilized), and multi-architecture scheduling.

## When to Invoke
Invoke this skill whenever you need to:
- setup karpenter nodepool
- configure ec2nodeclass karpenter
- consolidate k8s nodes karpenter

## Execution SOP & Rules
1. Create EC2NodeClass: apiVersion: karpenter.k8s.aws/v1beta1 with subnetSelectorTerms and amiFamily.
2. Create NodePool: apiVersion: karpenter.sh/v1beta1 defining requirements (instance-family, capacity-type: [spot, on-demand]).
3. Set disruption.consolidationPolicy: WhenUnderutilized to automatically drain and remove idle nodes.
4. Inspect Karpenter controller logs: kubectl logs -n karpenter -l app.kubernetes.io/name=karpenter -f.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
