karpenter-provider-aws icon indicating copy to clipboard operation
karpenter-provider-aws copied to clipboard

No ability to set dynamic value for kubeReserved cpu

Open jukie opened this issue 6 months ago • 7 comments

Description

What problem are you trying to solve? I'd like the ability to set a common kubelet configuration value for maxPods and kubeReserved.memory but would like to retain the dynamic cpu configuration that's used in the eks bootstrap.sh . This is because settings kubelet.maxPods alone doesn't lead to any changes in kubelet.kubeReserved as those values will still be generated based on /etc/eks/eni-max-pods.txt

If I only set kubeReserved.memory kubelet will fail to start due to an invalid config and if I override the value in bootstrap.sh during userdata execution Karpenter is then unaware of the actual values when making scheduling decisions.

Is there a way to configure a NodePool in a way that would allow for setting a static value for kubeReserved.memory while also allowing for the dynamic CPU configuration from bootstrap.sh?

# Calculates the amount of CPU to reserve for kubeReserved in millicores from the total number of vCPUs available on the instance.
# From the total core capacity of this worker node, we calculate the CPU resources to reserve by reserving a percentage
# of the available cores in each range up to the total number of cores available on the instance.
# We are using these CPU ranges from GKE (https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture#node_allocatable):
# 6% of the first core
# 1% of the next core (up to 2 cores)
# 0.5% of the next 2 cores (up to 4 cores)
# 0.25% of any cores above 4 cores
# Return:
#   CPU resources to reserve in millicores (m)
get_cpu_millicores_to_reserve() {
  local total_cpu_on_instance=$(($(nproc) * 1000))
  local cpu_ranges=(0 1000 2000 4000 $total_cpu_on_instance)
  local cpu_percentage_reserved_for_ranges=(600 100 50 25)
  cpu_to_reserve="0"
  for i in "${!cpu_percentage_reserved_for_ranges[@]}"; do
    local start_range=${cpu_ranges[$i]}
    local end_range=${cpu_ranges[(($i + 1))]}
    local percentage_to_reserve_for_range=${cpu_percentage_reserved_for_ranges[$i]}
    cpu_to_reserve=$(($cpu_to_reserve + $(get_resource_to_reserve_in_range $total_cpu_on_instance $start_range $end_range $percentage_to_reserve_for_range)))
  done
  echo $cpu_to_reserve
}

How important is this feature to you? Very important and would be willing to contribute this feature

  • 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

jukie avatar Aug 06 '24 23:08 jukie