Skip to content

Commit

Permalink
Calculate max pods
Browse files Browse the repository at this point in the history
  • Loading branch information
nerahou committed May 17, 2024
1 parent 0378e9e commit 44f8493
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
17 changes: 17 additions & 0 deletions cluster_connect.sh.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Calculate max pods
if [[ "${use_max_pods}" = "false" ]]; then
KUBELET_CONFIG=/etc/kubernetes/kubelet/kubelet-config.json
set +o pipefail
export CNI_VERSION=$(echo "${cni_version}" | sed 's/^v//')
MAX_PODS=$(/etc/eks/max-pods-calculator.sh --instance-type-from-imds \
--cni-version $CNI_VERSION \
%{ if show_max_allowed } --show-max-allowed%{ endif } \
--cni-custom-networking-enabled)
set -o pipefail
if [[ -n "$MAX_PODS" ]]; then
echo "$(jq ".maxPods=$MAX_PODS" $KUBELET_CONFIG)" > $KUBELET_CONFIG
else
echo "Not able to determine maxPods for instance. Not setting max pods for kubelet"
fi
fi

/etc/eks/bootstrap.sh ${cluster_name} \
--use-max-pods ${use_max_pods} \
--kubelet-extra-args '--node-labels=${node_labels} --register-with-taints=${node_taints} ${kubelet_extra_args}' \
Expand Down
4 changes: 3 additions & 1 deletion node_group_advanced.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ resource "aws_launch_template" "quortex_launch_tpl" {
)
: "${k}=${v}"]
)
use_max_pods = var.node_use_max_pods
use_max_pods = var.node_use_max_pods
cni_version = try(var.cluster_addons["vpc-cni"].version, "")
show_max_allowed = var.node_use_max_pods_allowed
}
)
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ variable "node_use_max_pods" {
description = "Set to false to prevent EKS from setting --max-pods in Kubelet config. By default, EKS sets the maximum number of pods that can run on the node, based on the instance type. Disabling this can be useful when using a CNI other than the default, like Calico."
}

variable "node_use_max_pods_allowed" {
type = bool
default = false
description = "Set to use max number of pods allowed to run in node instead of recommended value"
}

variable "instance_profile_name" {
type = string
description = "A name for the instance profile resource in AWS. Used only when node_groups_advanced is used."
Expand Down

0 comments on commit 44f8493

Please sign in to comment.