diff --git a/CHANGELOG.md b/CHANGELOG.md index 332fa94..7412f84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Added + - Added `market_type` to `workers_launch_template.tf` allow the usage of spot nodegroups without mixed instances policy. - Added support for log group tag in `./cluster.tf` (@lucas-giaco) - Added support for workers iam role tag in `./workers.tf` (@lucas-giaco) - Write your awesome addition here (by @you) diff --git a/docs/spot-instances.md b/docs/spot-instances.md index ef9df35..33bd807 100644 --- a/docs/spot-instances.md +++ b/docs/spot-instances.md @@ -84,6 +84,18 @@ Launch Template support is a recent addition to both AWS and this module. It mig kubelet_extra_args = "--node-labels=kubernetes.io/lifecycle=spot" } ] + + worker_groups_launch_template = [ + { + name = "spot-2" + instance_type = "m4.xlarge" + asg_max_size = 5 + asg_desired_size = 5 + autoscaling_enabled = true + kubelet_extra_args = "--node-labels=kubernetes.io/lifecycle=spot" + market_type = "spot" + } + ] ``` ## Important issues diff --git a/local.tf b/local.tf index 07c3504..ee1591b 100644 --- a/local.tf +++ b/local.tf @@ -56,6 +56,7 @@ locals { root_encrypted = "" # Whether the volume should be encrypted or not eni_delete = true # Delete the ENI on termination (if set to false you will have to manually delete before destroying) cpu_credits = "standard" # T2/T3 unlimited mode, can be 'standard' or 'unlimited'. Used 'standard' mode as default to avoid paying higher costs + market_type = null # Settings for launch templates with mixed instances policy override_instance_types = ["m5.large", "m5a.large", "m5d.large", "m5ad.large"] # A list of override instance types for mixed instances policy on_demand_allocation_strategy = "prioritized" # Strategy to use when launching on-demand instances. Valid values: prioritized. diff --git a/workers_launch_template.tf b/workers_launch_template.tf index 44bcd21..df4a231 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -229,6 +229,14 @@ resource "aws_launch_template" "workers_launch_template" { ) } + dynamic instance_market_options { + iterator = item + for_each = lookup(var.worker_groups_launch_template[count.index], "market_type", null) == null ? [] : list(lookup(var.worker_groups_launch_template[count.index], "market_type", null)) + content { + market_type = item.value + } + } + block_device_mappings { device_name = lookup( var.worker_groups_launch_template[count.index],