How aws/karpenter-provider-aws works
This repository is the AWS cloud provider for Karpenter, which provisions and removes Kubernetes nodes to satisfy unschedulable workloads. The principal flow runs from Karpenter’s scheduling/provisioning engine through the provider’s cloud-provider interface, AWS instance-type and launch configuration resolution, and EC2 fleet operations; resulting NodeClaims and Nodes are managed through Kubernetes. Separate branches cover NodeClass reconciliation, interruption handling, capacity reservations, zonal-shift awareness, pricing, and metrics. The README describes the overall workflow; sampled controller excerpts support selected reconciliation and integration links, so unsampled wiring is left out.
Main entry points: cloudprovider.go AWS cloud provider · operator.go Provider operator · controllers.go Controller registration · launchtemplate.go Launch templates
Components 25
Runtime and API
- Provider operator
pkg/operator/operator.go - Provider APIs
pkg/apis/v1/ec2nodeclass.go - AWS cloud provider
pkg/cloudprovider/cloudprovider.go - Controller registration
pkg/controllers/controllers.go
NodeClass configuration
- NodeClass reconciliation
pkg/controllers/nodeclass/controller.go - Class resource providers
pkg/controllers/nodeclass - AMI and bootstrap
pkg/providers/amifamily
Instance provisioning
- Instance type offerings
pkg/providers/instancetype/instancetype.go - Launch templates
pkg/providers/launchtemplate/launchtemplate.go - EC2 request batching
pkg/batcher/ec2api.go - Instance provider
pkg/providers/instance/instance.go
Node lifecycle
- NodeClaim cleanup
pkg/controllers/nodeclaim/garbagecollection/controller.go - NodeClaim tagging
pkg/controllers/nodeclaim/tagging/controller.go - Interruption handling
pkg/controllers/interruption/controller.go - Instance health checks
pkg/controllers/interruption/instancestatus_controller.go - Reservation lifecycle
pkg/controllers/capacityreservation/expiration/controller.go - Zonal shift detection
pkg/controllers/arczonalshift/controller.go
Capacity signals
- Pricing provider
pkg/providers/pricing/pricing.go - Offering metrics
pkg/controllers/metrics/controller.go
Other components
- Unschedulable pods
- Karpenter engine
- Kubernetes API
- Amazon EC2
- Interruption queue
pkg/providers/sqs/sqs.go - AWS services
Connections 33
- Unschedulable pods → Karpenter engine: trigger scheduling
- Karpenter engine → Kubernetes API: read workloads
- Karpenter engine → AWS cloud provider: request capacity
- Provider operator → Controller registration: register controllers
- Provider operator → AWS cloud provider: initialize provider
- Provider operator → Provider APIs: install API types
- Controller registration → NodeClass reconciliation: register reconciliation
- Controller registration → Interruption handling: register handling
- AWS cloud provider → Kubernetes API: read NodeClaims
- AWS cloud provider → Instance type offerings: resolve offerings
- AWS cloud provider → Launch templates: build launch data
- AWS cloud provider → EC2 request batching: create or terminate
- Instance type offerings → AWS services: query capacity data
- Launch templates → AMI and bootstrap: resolve bootstrap
- Launch templates → Class resource providers: resolve class resources
- EC2 request batching → Amazon EC2: submit fleet requests
- Instance provider → Amazon EC2: query and tag instances
- NodeClaim cleanup → AWS cloud provider: list and delete claims
- NodeClaim cleanup → Kubernetes API: read and delete Nodes
- NodeClaim tagging → Instance provider: inspect and tag
- NodeClaim tagging → Kubernetes API: patch NodeClaim
- Interruption handling → Interruption queue: consume notices
- Interruption handling → Kubernetes API: cordon or drain
- Instance health checks → AWS services: poll instance status
- Instance health checks → Kubernetes API: handle unhealthy nodes
- Reservation lifecycle → AWS services: check reservations
- Reservation lifecycle → Kubernetes API: delete expiring claims
- Zonal shift detection → AWS services: inspect shifted zones
- Zonal shift detection → Kubernetes API: read NodePools and NodeClasses
- Offering metrics → Kubernetes API: list NodePools
- Offering metrics → AWS cloud provider: get instance types
- AWS cloud provider → Pricing provider: resolve offering prices
- Class resource providers → AWS services: resolve AWS resources