Description
What
Add support for cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size annotation to enforce per-MachineDeployment node limits.
Why
It is not something that is part of the core Karpenter contract, but it can be useful in case of CAPI providers where the user wants to enforce per-MachineDeployment node limits.
Especially, when they group multiple MachineDeployments under one NodePool as instance types for cost effective scheduling. While NodePool do offer spec.limits on the NodePool level, it does not control how much a particular MachineDeployment can be scaled.
The max-size annotation can help in putting a cap on the number of nodes per MachineDeployment. Same as cluster-api-autoscaler does.
Proposed Changes
The change will require reading the annotation and comparing it against the MachineDeployment's spec.replicas. If spec.replicas >= max-size, then set Available: false in the offering.
This will plug seamlessly with Available flag while support for capacity-types (reserved, on-demand, spot) and pricing is added in the offering in the future.
If this looks good, I can open a PR for this.
Description
What
Add support for
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-sizeannotation to enforce per-MachineDeployment node limits.Why
It is not something that is part of the core Karpenter contract, but it can be useful in case of CAPI providers where the user wants to enforce per-MachineDeployment node limits.
Especially, when they group multiple MachineDeployments under one NodePool as instance types for cost effective scheduling. While NodePool do offer spec.limits on the NodePool level, it does not control how much a particular MachineDeployment can be scaled.
The max-size annotation can help in putting a cap on the number of nodes per MachineDeployment. Same as cluster-api-autoscaler does.
Proposed Changes
The change will require reading the annotation and comparing it against the MachineDeployment's
spec.replicas. Ifspec.replicas>=max-size, then setAvailable: falsein the offering.This will plug seamlessly with Available flag while support for capacity-types (reserved, on-demand, spot) and pricing is added in the offering in the future.
If this looks good, I can open a PR for this.