Skip to content

Karpenter consolidateAfter is not working as expected #2705

Description

@mallow111

Description

For consolidateAfter, can we make -> consolidateAfter is the amount of time Karpenter should wait to have a node as part of the consolidation process. The amount of time Karpenter has to wait until pods can move into the node and out of the node due to consolidation. What we want is that when a node has a pod movement (pod added or removed for any reason - k8s scale up/down, consolidation, drift, etc.) then this node is invisible for the Karpenter underutilized consolidation process

  • E.g How can we avoid nodes are disturbed before the 30min(consolidateAfter setting) configuration?

  • E.g We want to know what is the logic behind picking a node for consolidation, for those perfectly packed nodes, can we avoid picking them for consolidation before 30min(the consolidateAfter period)?It is ok to consolidate these nodes after 30min.

  • E.g We also concerned the new nodes who joined in the cluster recently can get consolidated in a short period of time again(it's OK to consolidate them after 30min)

Observed Behavior:
We have the following settings:

disruption:
    consolidationPolicy: WhenEmptyOrUnderutilized
    consolidateAfter: 30m
    budgets:
    # Drifted nodes limited to terminate 10% in parallel
       - nodes: "10%"
       reasons:
         - Drifted
    # Underutilized nodes always compacting to avoid a low packing growth
      - nodes: "5%"
      reasons:
        - Underutilized
    # Empty nodes can be terminated any time

Image
  • Some well-packed nodes get interrupted
  • Several pods are disrupted unnecessarily.
  • The interruption is too frequent even if we set consolidateAfter: 30m

Expected Behavior:

Image
  • We expect to see only 3 nodes get consolidated at this moment since they are empty now, other nodes and pods get untouched

Reproduction Steps (Please include YAML):
Nodepool yaml

apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: aaa
spec:
    disruption:
      consolidationPolicy: WhenEmptyOrUnderutilized
      consolidateAfter: 30m
      budgets:
      # Drifted nodes limited to terminate 10% in parallel
         - nodes: "10%"
         reasons:
           - Drifted
      # Underutilized nodes always compacting to avoid a low packing growth
        - nodes: "5%"
        reasons:
          - Underutilized
      # Empty nodes can be terminated any time
    template:
      spec:
        expireAfter: Never
        nodeClassRef:
          group: karpenter.k8s.aws
          kind: EC2NodeClass
          name: nearcorepool2
        requirements:
        - key: kubernetes.io/arch
          operator: In
          values:
          - arm64
          - amd64
        - key: karpenter.sh/capacity-type
          operator: In
          values:
          - on-demand
        - key: node.kubernetes.io/instance-type
          operator: In
          values:
          - m7i.8xlarge
        taints:
        - effect: NoSchedule
          key: dedicated
          value: aaa

In the workload, we just set the toleration to use this nodepool

  Node-Selectors:  nodepool=aaa
  Tolerations:  dedicated=aaa:NoSchedule

Versions:

  • Chart Version: 1.3.3
  • Kubernetes Version (kubectl version): The bug is not related to k8s version.
  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.needs-prioritytriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions