Skip to content

Suspend AZRebalance in on-demand autoscaling group #1585

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

Merged
merged 3 commits into from
Nov 23, 2020
Merged
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
24 changes: 14 additions & 10 deletions manager/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ function create_eks() {
eksctl create cluster --timeout=$EKSCTL_TIMEOUT --install-neuron-plugin=false -f /workspace/eks.yaml
echo

if [ "${CORTEX_SPOT,,}" == "true" ]; then
suspend_spot_az_rebalance
fi
suspend_az_rebalance

write_kubeconfig
}
Expand Down Expand Up @@ -325,14 +323,20 @@ function resize_nodegroup() {
fi
}

function suspend_spot_az_rebalance() {
asg_info=$(aws autoscaling describe-auto-scaling-groups --region $CORTEX_REGION --query "AutoScalingGroups[?contains(Tags[?Key==\`alpha.eksctl.io/cluster-name\`].Value, \`$CORTEX_CLUSTER_NAME\`)]|[?contains(Tags[?Key==\`alpha.eksctl.io/nodegroup-name\`].Value, \`ng-cortex-worker-spot\`)]")
asg_name=$(echo "$asg_info" | jq -r 'first | .AutoScalingGroupName')
if [ "$asg_name" = "" ] || [ "$asg_name" = "null" ]; then
echo -e "unable to find autoscaling group name from info:\n$asg_info"
exit 1
function suspend_az_rebalance() {
asg_on_demand_info=$(aws autoscaling describe-auto-scaling-groups --region $CORTEX_REGION --query "AutoScalingGroups[?contains(Tags[?Key==\`alpha.eksctl.io/cluster-name\`].Value, \`$CORTEX_CLUSTER_NAME\`)]|[?contains(Tags[?Key==\`alpha.eksctl.io/nodegroup-name\`].Value, \`ng-cortex-worker-on-demand\`)]")
asg_on_demand_length=$(echo "$asg_on_demand_info" | jq -r 'length')
if (( "$asg_on_demand_length" > "0" )); then
asg_on_demand_name=$(echo "$asg_on_demand_info" | jq -r 'first | .AutoScalingGroupName')
aws autoscaling suspend-processes --region $CORTEX_REGION --auto-scaling-group-name $asg_on_demand_name --scaling-processes AZRebalance
fi

asg_spot_info=$(aws autoscaling describe-auto-scaling-groups --region $CORTEX_REGION --query "AutoScalingGroups[?contains(Tags[?Key==\`alpha.eksctl.io/cluster-name\`].Value, \`$CORTEX_CLUSTER_NAME\`)]|[?contains(Tags[?Key==\`alpha.eksctl.io/nodegroup-name\`].Value, \`ng-cortex-worker-spot\`)]")
asg_spot_length=$(echo "$asg_spot_info" | jq -r 'length')
if (( "$asg_spot_length" > "0" )); then
asg_spot_name=$(echo "$asg_spot_info" | jq -r 'first | .AutoScalingGroupName')
aws autoscaling suspend-processes --region $CORTEX_REGION --auto-scaling-group-name $asg_spot_name --scaling-processes AZRebalance
fi
aws autoscaling suspend-processes --region $CORTEX_REGION --auto-scaling-group-name $asg_name --scaling-processes AZRebalance
}

function create_vpc_link() {
Expand Down