From d577016947343d773c6b0e661bd7505b8c18b440 Mon Sep 17 00:00:00 2001 From: Thomas O'Neill Date: Wed, 5 Aug 2020 16:21:10 -0400 Subject: [PATCH 1/3] Add example for lauch config with mixed lifecycles --- docs/spot-instances.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/spot-instances.md b/docs/spot-instances.md index 1eb4da4257..ca2ff856fe 100644 --- a/docs/spot-instances.md +++ b/docs/spot-instances.md @@ -83,6 +83,25 @@ Launch Template support is a recent addition to both AWS and this module. It mig ] ``` +## Using Launch Templates With Both On Demand +Launch template to launch 2 on demand instances of type M5.Large, and have the ability to scale up using spot instances and on demand instances. The node labels will be either "on-demand" or "spot" depending on which is launched using the EC2 meta-data. With `on_demand_percentage_above_base_capacity` set to 25, 1 in 4 new nodes when auto-scaling will be an on-demand instance. If not set, all new nodes will be spot instances. +```hcl + worker_groups_launch_template { + name = "mixed-demand-spot" + override_instance_types = ["m5.large", "m5a.large", "m4.large"] + root_encrypted = true + root_volume_size = 50 + + asg_min_size = 2 + asg_desired_capacity = 2 + on_demand_base_capacity = 3 + on_demand_percentage_above_base_capacity = 25 + asg_max_size = 20 + spot_instance_pools = 3 + + kubelet_extra_args = "--node-labels=node.kubernetes.io/lifecycle=`curl -s http://169.254.169.254/latest/meta-data/instance-life-cycle`" + } +``` ## Important Notes An issue with the cluster-autoscaler: https://github.com/kubernetes/autoscaler/issues/1133 From fe373247a69dec306a09e1aae55f88a864e46944 Mon Sep 17 00:00:00 2001 From: Thomas O'Neill Date: Wed, 5 Aug 2020 16:22:34 -0400 Subject: [PATCH 2/3] Set what on-demand instance is --- docs/spot-instances.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/spot-instances.md b/docs/spot-instances.md index ca2ff856fe..1fd74ef960 100644 --- a/docs/spot-instances.md +++ b/docs/spot-instances.md @@ -84,7 +84,7 @@ Launch Template support is a recent addition to both AWS and this module. It mig ``` ## Using Launch Templates With Both On Demand -Launch template to launch 2 on demand instances of type M5.Large, and have the ability to scale up using spot instances and on demand instances. The node labels will be either "on-demand" or "spot" depending on which is launched using the EC2 meta-data. With `on_demand_percentage_above_base_capacity` set to 25, 1 in 4 new nodes when auto-scaling will be an on-demand instance. If not set, all new nodes will be spot instances. +Launch template to launch 2 on demand instances of type M5.Large, and have the ability to scale up using spot instances and on demand instances. The node labels will be either "on-demand" or "spot" depending on which is launched using the EC2 meta-data. With `on_demand_percentage_above_base_capacity` set to 25, 1 in 4 new nodes when auto-scaling will be an on-demand instance. If not set, all new nodes will be spot instances. The on-demand types will be the primary instance type (first in the array if they are not weighted). ```hcl worker_groups_launch_template { name = "mixed-demand-spot" From 98c31606742ba629569c5b93acbac02f2d4b28e9 Mon Sep 17 00:00:00 2001 From: Daniel Piddock Date: Fri, 14 Aug 2020 15:55:14 +0200 Subject: [PATCH 3/3] Tweak wording --- docs/spot-instances.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/spot-instances.md b/docs/spot-instances.md index 1fd74ef960..442c228ebc 100644 --- a/docs/spot-instances.md +++ b/docs/spot-instances.md @@ -83,10 +83,14 @@ Launch Template support is a recent addition to both AWS and this module. It mig ] ``` -## Using Launch Templates With Both On Demand -Launch template to launch 2 on demand instances of type M5.Large, and have the ability to scale up using spot instances and on demand instances. The node labels will be either "on-demand" or "spot" depending on which is launched using the EC2 meta-data. With `on_demand_percentage_above_base_capacity` set to 25, 1 in 4 new nodes when auto-scaling will be an on-demand instance. If not set, all new nodes will be spot instances. The on-demand types will be the primary instance type (first in the array if they are not weighted). +## Using Launch Templates With Both Spot and On Demand + +Example launch template to launch 2 on demand instances of type m5.large, and have the ability to scale up using spot instances and on demand instances. The `node.kubernetes.io/lifecycle` node label will be set to the value queried from the EC2 meta-data service: either "on-demand" or "spot". + +`on_demand_percentage_above_base_capacity` is set to 25 so 1 in 4 new nodes, when auto-scaling, will be on-demand instances. If not set, all new nodes will be spot instances. The on-demand instances will be the primary instance type (first in the array if they are not weighted). + ```hcl - worker_groups_launch_template { + worker_groups_launch_template = [{ name = "mixed-demand-spot" override_instance_types = ["m5.large", "m5a.large", "m4.large"] root_encrypted = true @@ -100,8 +104,9 @@ Launch template to launch 2 on demand instances of type M5.Large, and have the a spot_instance_pools = 3 kubelet_extra_args = "--node-labels=node.kubernetes.io/lifecycle=`curl -s http://169.254.169.254/latest/meta-data/instance-life-cycle`" - } + }] ``` + ## Important Notes An issue with the cluster-autoscaler: https://github.com/kubernetes/autoscaler/issues/1133