|
| 1 | +# Placement Group Support |
| 2 | + |
| 3 | +## Context |
| 4 | + |
| 5 | +Amazon EC2 placement groups let operators influence instance placement for low-latency (`cluster`), failure-domain isolation (`partition`), and small critical workloads (`spread`). The long-standing request in https://github.com/aws/karpenter-provider-aws/issues/3324 is to make these groups usable from `EC2NodeClass`. |
| 6 | + |
| 7 | +Karpenter already treats `EC2NodeClass` as launch configuration for existing AWS resources such as subnets, security groups, AMIs, and instance profiles. Placement groups fit best when modeled the same way. |
| 8 | + |
| 9 | +## Problem |
| 10 | + |
| 11 | +Users can launch Karpenter-managed nodes into subnets, security groups, and capacity reservations, but cannot direct those nodes into an existing placement group. This blocks workloads that already rely on EC2 placement-group semantics, for example: |
| 12 | + |
| 13 | +- tightly-coupled clusters that need cluster placement-group networking |
| 14 | +- replicated systems that want partition placement-group isolation |
| 15 | +- small critical workloads that want spread placement-group separation |
| 16 | + |
| 17 | +The previously proposed design in #5389 focused on Karpenter creating placement groups. That adds a new EC2 resource lifecycle to reconcile and exposes strategy-specific creation APIs that users may rely on long term. |
| 18 | + |
| 19 | +## Options |
| 20 | + |
| 21 | +### Option 1: Karpenter creates and owns placement groups |
| 22 | + |
| 23 | +Pros: |
| 24 | + |
| 25 | +- users can describe strategy directly in `EC2NodeClass` |
| 26 | +- Karpenter could validate strategy-specific configuration at reconciliation time |
| 27 | + |
| 28 | +Cons: |
| 29 | + |
| 30 | +- introduces new lifecycle ownership for EC2 resources outside the current launch path |
| 31 | +- expands the stable API surface with strategy creation details such as `cluster`, `spread`, `partition`, partition count, and spread level |
| 32 | +- complicates shared placement groups and future AWS-specific variants |
| 33 | +- makes rollback and drift semantics harder because the placement group becomes a controller-managed dependency |
| 34 | + |
| 35 | +### Option 2: Karpenter references an existing placement group |
| 36 | + |
| 37 | +Pros: |
| 38 | + |
| 39 | +- matches how `EC2NodeClass` already models other AWS launch dependencies |
| 40 | +- keeps the API small: identify the group and optionally pin a partition |
| 41 | +- works for user-managed, shared, and externally tagged placement groups |
| 42 | +- avoids inventing a placement-group controller lifecycle before demand is proven |
| 43 | + |
| 44 | +Cons: |
| 45 | + |
| 46 | +- users must provision the placement group out of band |
| 47 | +- Karpenter cannot configure placement-group strategy on behalf of the user |
| 48 | + |
| 49 | +## Recommendation |
| 50 | + |
| 51 | +Add an optional `spec.placementGroup` field on `EC2NodeClass`: |
| 52 | + |
| 53 | +```yaml |
| 54 | +spec: |
| 55 | + placementGroup: |
| 56 | + name: analytics-partition |
| 57 | + partition: 2 |
| 58 | +``` |
| 59 | +
|
| 60 | +Behavior: |
| 61 | +
|
| 62 | +- `name` or `id` identifies the existing placement group; the fields are mutually exclusive |
| 63 | +- `id` supports shared placement groups, which require `GroupId` during launch |
| 64 | +- `partition` is optional and only meaningful for partition placement groups |
| 65 | +- Karpenter resolves the configured group into `status.placementGroup` |
| 66 | +- launch templates include the placement-group reference so both `CreateFleet` and `RunInstances` honor it |
| 67 | + |
| 68 | +## Key Decisions |
| 69 | + |
| 70 | +- Karpenter does not create, tag, delete, or mutate placement groups in this design |
| 71 | +- placement-group strategy remains an operator concern because it belongs to the EC2 placement-group resource, not the instance launch request |
| 72 | +- partition selection is the only launch-time knob worth exposing initially because AWS applies it at instance launch and it is useful even when the placement group is created elsewhere |
| 73 | + |
| 74 | +## User Guidance |
| 75 | + |
| 76 | +- Use `name` for placement groups in the same account and `id` for shared placement groups |
| 77 | +- Pair cluster placement groups with subnet or topology constraints that keep launches in a single Availability Zone |
| 78 | +- Omit `partition` to let EC2 distribute instances across partitions, or set it when the workload needs explicit partition affinity |
| 79 | + |
| 80 | +## Future Work |
| 81 | + |
| 82 | +- richer status surfacing for placement-group strategy and readiness |
| 83 | +- strategy-aware validation and scheduling hints |
| 84 | +- a separate proposal for Karpenter-managed placement-group lifecycle if real demand justifies the larger API |
0 commit comments