-
Notifications
You must be signed in to change notification settings - Fork 1
/
04_cluster_autoscaler.sh
executable file
·29 lines (20 loc) · 1.89 KB
/
04_cluster_autoscaler.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/bash
set -eo pipefail
source ./common.sh
# Cluster Autoscaler
pwd=$(pwd)
export nodegroupa="$name-ng-a"
export nodegroupb="$name-ng-b"
STACK_NAME_A=$(eksctl get nodegroup --cluster "$name" --name "$nodegroupa" -o json | jq -r '.[].StackName')
#INSTANCE_PROFILE_ARN_A=$(aws cloudformation describe-stacks --stack-name $STACK_NAME_A | jq -r '.Stacks[].Outputs[] | select(.OutputKey=="InstanceProfileARN") | .OutputValue')
ROLE_NAME_A=$(aws cloudformation describe-stacks --stack-name $STACK_NAME_A | jq -r '.Stacks[].Outputs[] | select(.OutputKey=="InstanceRoleARN") | .OutputValue' | cut -f2 -d/)
aws iam put-role-policy --role-name $ROLE_NAME_A --policy-name ASG-Policy-For-Worker --policy-document file://$pwd/modules/scaling/asg-policy.json
export ASG_NAME_A=$(aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[].[AutoScalingGroupName]' --output text | grep "eksctl-$name-nodegroup-$name-ng-a")
STACK_NAME_B=$(eksctl get nodegroup --cluster "$name" --name "$nodegroupb" -o json | jq -r '.[].StackName')
#INSTANCE_PROFILE_ARN_B=$(aws cloudformation describe-stacks --stack-name $STACK_NAME_B | jq -r '.Stacks[].Outputs[] | select(.OutputKey=="InstanceProfileARN") | .OutputValue')
ROLE_NAME_B=$(aws cloudformation describe-stacks --stack-name $STACK_NAME_B | jq -r '.Stacks[].Outputs[] | select(.OutputKey=="InstanceRoleARN") | .OutputValue' | cut -f2 -d/)
aws iam put-role-policy --role-name $ROLE_NAME_B --policy-name ASG-Policy-For-Worker --policy-document file://$pwd/modules/scaling/asg-policy.json
export ASG_NAME_B=$(aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[].[AutoScalingGroupName]' --output text | grep "eksctl-$name-nodegroup-$name-ng-b")
j2 modules/scaling/cluster-autoscaler.yml.j2 > modules/scaling/cluster-autoscaler.yml --undefined
kubectl apply -f modules/scaling/cluster-autoscaler.yml
# kubectl logs -f deployment/cluster-autoscaler -n kube-system