From 9cba6eada438d4c05343fd2fcdcda46e159a7bfc Mon Sep 17 00:00:00 2001 From: Samseppiol Date: Thu, 23 Apr 2020 17:53:57 +1000 Subject: [PATCH] Enable node scaling functionality with asg tags --- eks-cluster.cfhighlander.rb | 2 +- eks-cluster.cfndsl.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/eks-cluster.cfhighlander.rb b/eks-cluster.cfhighlander.rb index 4c6b040..4edc6f3 100644 --- a/eks-cluster.cfhighlander.rb +++ b/eks-cluster.cfhighlander.rb @@ -14,7 +14,7 @@ ComponentParam 'InstanceType' ComponentParam 'SpotPrice', '' - + ComponentParam 'EnableScaling', 'true' ComponentParam 'DesiredCapacity', '1' ComponentParam 'MinSize', '1' ComponentParam 'MaxSize', '2' diff --git a/eks-cluster.cfndsl.rb b/eks-cluster.cfndsl.rb index 675322b..12b282d 100644 --- a/eks-cluster.cfndsl.rb +++ b/eks-cluster.cfndsl.rb @@ -178,6 +178,12 @@ LaunchTemplateData(template_data) } + asg_tags = [ + { Key: FnSub("k8s.io/cluster/${EksCluster}"), Value: 'owned' }, + { Key: 'k8s.io/cluster-autoscaler/enabled', Value: Ref('EnableScaling') } + ] + asg_tags += tags + asg_tags.each {|tag| tag[:PropagateAtLaunch] = true } AutoScaling_AutoScalingGroup(:EksNodeAutoScalingGroup) { UpdatePolicy(:AutoScalingRollingUpdate, { MaxBatchSize: '1', @@ -193,6 +199,7 @@ LaunchTemplateId: Ref(:EksNodeLaunchTemplate), Version: FnGetAtt(:EksNodeLaunchTemplate, :LatestVersionNumber) }) + Tags asg_tags }