Karpenter currently supports Gt (greater than) and Lt (less than) operators for numeric requirements. These are strict inequalities, which creates an awkward user experience. For example, to require a minimum of 2 CPUs, users must specify Gt 1 instead of the more intuitive Gte 2.
Users frequently need to express inclusive bounds on numeric requirements like CPU count, memory, or GPU count. The current off-by-one interface is confusing and error-prone:
| User Intent | Current Syntax | Proposed Syntax |
|---|---|---|
| At least 2 CPUs | Gt 1 |
Gte 2 |
| At most 8 CPUs | Lt 9 |
Lte 8 |
Add two new operators to Karpenter's requirement system:
Gte- Greater than or equal toLte- Less than or equal to
apiVersion: karpenter.sh/v1
kind: NodePool
spec:
template:
spec:
requirements:
- key: karpenter.k8s.aws/instance-cpu
operator: Gte # New operator
values: ["2"]
- key: karpenter.k8s.io/instance-memory
operator: Lte # New operator
values: ["64"]- Define new operator constants in
pkg/apis/v1/ - Add
greaterThanOrEqualandlessThanOrEqualfields to theRequirementstruct - Update
NewRequirementWithFlexibilityto handleGteandLte - Update validation to accept the new operators
- Update intersection and comparison logic
- Existing
GtandLtoperators remain unchanged - New operators are additive; no breaking changes
- Automatic conversion: Convert
Gte NtoGt N-1internally. Rejected because it loses semantic meaning and complicates debugging. - Documentation only: Document the off-by-one pattern. Rejected because it doesn't solve the UX problem.