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 16, 2024
1 parent 0378e9e commit 0494ded
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cluster_connect.sh.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Determine instance type
INSTANCE_TYPE=$(TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \
&& curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-type)

# Calculate max pods
if [[ "${use_max_pods}" = "false" ]]; then
KUBELET_CONFIG=/etc/kubernetes/kubelet/kubelet-config.json
set +o pipefail
CNI_VERSION=$(echo "${cni_version}" | sed 's/^v//')
MAX_PODS=$(/etc/eks/max-pods-calculator.sh --instance-type $INSTANCE_TYPE --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_TYPE. 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
1 change: 1 addition & 0 deletions node_group_advanced.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
}
)
}
Expand Down

0 comments on commit 0494ded

Please sign in to comment.