From c751c2bbda03b9a39dae41620e2e1b6cb9c73b04 Mon Sep 17 00:00:00 2001 From: nerahou Date: Tue, 14 May 2024 10:07:05 +0200 Subject: [PATCH] Calculate max pods --- cluster_connect.sh.tpl | 15 +++++++++++++++ node_group_advanced.tf | 1 + 2 files changed, 16 insertions(+) diff --git a/cluster_connect.sh.tpl b/cluster_connect.sh.tpl index 387fcec..968e4e5 100644 --- a/cluster_connect.sh.tpl +++ b/cluster_connect.sh.tpl @@ -1,3 +1,18 @@ +# 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//') + export CNI_CUSTOM_NETWORKING_ENABLED=true + MAX_PODS=$(/etc/eks/max-pods-calculator.sh --instance-type-from-imds --cni-version $CNI_VERSION --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}' \ diff --git a/node_group_advanced.tf b/node_group_advanced.tf index bc2d466..f883bb9 100644 --- a/node_group_advanced.tf +++ b/node_group_advanced.tf @@ -121,6 +121,7 @@ resource "aws_launch_template" "quortex_launch_tpl" { : "${k}=${v}"] ) use_max_pods = var.node_use_max_pods + cni_version = try(var.cluster_addons["vpc-cni"].version, "") } ) }