Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: calculate the correct number of pods for custom ENIConfig #494

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions files/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function print_help {
echo ""
echo "-h,--help print this help"
echo "--use-max-pods Sets --max-pods for the kubelet when true. (default: true)"
echo "--using-custom-eniconfig Calculates --max-pods for use with custom ENIConfig. (default: false)"
echo "--b64-cluster-ca The base64 encoded cluster CA content. Only valid when used with --apiserver-endpoint. Bypasses calling \"aws eks describe-cluster\""
echo "--apiserver-endpoint The EKS cluster API Server endpoint. Only valid when used with --b64-cluster-ca. Bypasses calling \"aws eks describe-cluster\""
echo "--kubelet-extra-args Extra arguments to add to the kubelet. Useful for adding labels or taints."
Expand All @@ -40,6 +41,11 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--using-custom-eniconfig)
USING_CUSTOM_ENICONFIG="$2"
shift
shift
;;
--b64-cluster-ca)
B64_CLUSTER_CA=$2
shift
Expand Down Expand Up @@ -98,6 +104,7 @@ CLUSTER_NAME="$1"
set -u

USE_MAX_PODS="${USE_MAX_PODS:-true}"
USING_CUSTOM_ENICONFIG="${USING_CUSTOM_ENICONFIG:-false}"
B64_CLUSTER_CA="${B64_CLUSTER_CA:-}"
APISERVER_ENDPOINT="${APISERVER_ENDPOINT:-}"
KUBELET_EXTRA_ARGS="${KUBELET_EXTRA_ARGS:-}"
Expand Down Expand Up @@ -281,12 +288,20 @@ INSTANCE_TYPE=$(curl -s http://169.254.169.254/latest/meta-data/instance-type)
# with this formula when scheduling pods: Allocatable = Capacity - Reserved - Eviction Threshold.

#calculate the max number of pods per instance type
MAX_PODS_FILE="/etc/eks/eni-max-pods.txt"
ENI_DATA_FILE="/etc/eks/instance-eni-data.txt"
set +o pipefail
MAX_PODS=$(cat $MAX_PODS_FILE | awk "/^$INSTANCE_TYPE/"' { print $2 }')
# * First IP on each ENI is not used for pods
# * 2 additional host-networking pods (AWS ENI and kube-proxy) are accounted for
MAX_PODS=$(cat $ENI_DATA_FILE | awk "/^$INSTANCE_TYPE/"' { print $2 * ($3 - 1) + 2 }')

# Handle cases where using custom ENIConfig
if [ $USING_CUSTOM_ENICONFIG ]; then
MAX_PODS=$(cat $ENI_DATA_FILE | awk "/^$INSTANCE_TYPE/"' { print ($2 - 1) * ($3 - 1) + 2 }')
fi

set -o pipefail
if [ -z "$MAX_PODS" ]; then
echo 'No entry for $INSTANCE_TYPE in $MAX_PODS_FILE'
echo 'No entry for $INSTANCE_TYPE in $ENI_DATA_FILE'
exit 1
fi

Expand Down
300 changes: 0 additions & 300 deletions files/eni-max-pods.txt

This file was deleted.

Loading