feat: Add annotation-based priority control for static NodePool deprovisioning#2842
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: adriananeci The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
370f683 to
b578bd7
Compare
|
Note for the reviewers: initial changes were minimal, but because they introduced a cyclomatic complexity issue I had to refactor the code a bit. |
Pull Request Test Coverage Report for Build 21879795034Details
💛 - Coveralls |
|
From a naming perspective, do we think that https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#pod-deletion-cost is an appropriate analog? cc: @jamesmt-aws. I think we may want to support something like this for dynamic provisioning as well, to provide customers with a way to give Karpenter hints about their preferred consolidation choices. |
Refactor empty node filtering to use a dedicated function for improved readability and maintainability.
|
/retest |
Fixes #2841
Description
This PR adds support for the
karpenter.sh/deprovisioning-priorityannotation on NodeClaims, allowing users to explicitly control which nodes are removed first when scaling down static NodePools.When scaling down static NodePools, users need control over which specific nodes are removed. Current behavior selects nodes based on internal heuristics (empty nodes, disruption cost), but doesn't allow explicit targeting. This is problematic when:
Example scenarios from issue #2841:
Initial state: replicas=4, NodeClaims=[A, B, C, D], nodes don't have do-not-disrupt pods
User actions:
Expected:
Reality:
Initial state: replicas=4, NodeClaims=[A, B, C, D], nodes don't have do-not-disrupt pods
User actions:
Expected:
Reality:
This PR introduces
karpenter.sh/deprovisioning-priorityannotation with integer values (higher = deprovisioned first, default = 0). Priority is applied across all candidate selection tiers while maintaining safety guarantees.Deprovisioning priority hierarchy:
This hierarchy ensures safety-critical workloads remain protected while giving users fine-grained control over deprovisioning order.
Updated the docs from
designs/static-capacity.mddocs tooUsage Example
Use Cases
These changes should be fully backward compatibile since nodes without annotation default to priority 0
Also, existing deprovisioning behavior unchanged when annotation not used and invalid annotation values gracefully default to 0
Annotation based node priority deprovisioning inspiration came from https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#pod-deletion-cost
How was this change tested?
New test coverage includes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.