diff --git a/examples/aws-eks-distro/main.tf b/examples/aws-eks-distro/main.tf index eb2d17dc..97310283 100644 --- a/examples/aws-eks-distro/main.tf +++ b/examples/aws-eks-distro/main.tf @@ -151,9 +151,10 @@ module "worker_on_demand" { subnet_ids = module.network.private_subnet_ids instance_config = { - name = "on-demand" - count = 1 - image_id = module.os_ami.image_id + name = "on-demand" + count = 1 + max_count = null + image_id = module.os_ami.image_id ec2_type = [ "t3.medium", "t2.medium" @@ -175,9 +176,10 @@ module "worker_on_demand" { } asg_warm_pool = { - enabled = true - min_size = 1 - reuse_on_scale_in = false + enabled = true + min_size = 1 + reuse_on_scale_in = false + max_group_prepared_capacity = 1 } s3_bucket = module.master.ignition_s3_bucket @@ -203,9 +205,10 @@ module "worker_spot" { subnet_ids = module.network.private_subnet_ids instance_config = { - name = "spot" - image_id = module.os_ami.image_id - count = 2 + name = "spot" + image_id = module.os_ami.image_id + count = 2 + max_count = 10 ec2_type = [ "m5.large", "m4.large" diff --git a/examples/kubernetes-cluster/main.tf b/examples/kubernetes-cluster/main.tf index 40e8d0b5..672a6076 100644 --- a/examples/kubernetes-cluster/main.tf +++ b/examples/kubernetes-cluster/main.tf @@ -116,9 +116,10 @@ module "worker_on_demand" { subnet_ids = module.network.private_subnet_ids instance_config = { - name = "on-demand" - count = 1 - image_id = module.os_ami.image_id + name = "on-demand" + count = 1 + max_count = null + image_id = module.os_ami.image_id ec2_type = [ "t3.medium", "t2.medium" @@ -140,9 +141,10 @@ module "worker_on_demand" { } asg_warm_pool = { - enabled = true - min_size = 1 - reuse_on_scale_in = false + enabled = true + min_size = 1 + reuse_on_scale_in = false + max_group_prepared_capacity = 1 } kubelet_config = { @@ -179,9 +181,10 @@ module "worker_spot" { subnet_ids = module.network.private_subnet_ids instance_config = { - name = "spot" - image_id = module.os_ami.image_id - count = 2 + name = "spot" + image_id = module.os_ami.image_id + count = 2 + max_count = 10 ec2_type = [ "m5.large", "m4.large" diff --git a/modules/aws/kube-worker/main.tf b/modules/aws/kube-worker/main.tf index bb6a998c..09b2d517 100644 --- a/modules/aws/kube-worker/main.tf +++ b/modules/aws/kube-worker/main.tf @@ -16,7 +16,7 @@ locals { } } vpc_security_group_ids = var.enable_extra_sg ? concat([aws_security_group.worker_group[0].id], var.security_group_ids) : var.security_group_ids - asg_max_size = var.instance_config["count"] == 0 ? 3 : (var.instance_config["count"] * 3) + asg_max_size = var.instance_config["max_count"] != null ? var.instance_config["max_count"] : (var.instance_config["count"] == 0 ? 3 : (var.instance_config["count"] * 3)) } data "aws_subnet" "subnet" { @@ -56,7 +56,7 @@ resource "aws_autoscaling_group" "worker" { content { pool_state = "Stopped" min_size = var.asg_warm_pool["min_size"] - max_group_prepared_capacity = local.asg_max_size + max_group_prepared_capacity = var.asg_warm_pool["max_group_prepared_capacity"] instance_reuse_policy { reuse_on_scale_in = var.asg_warm_pool["reuse_on_scale_in"] diff --git a/modules/aws/kube-worker/variables.tf b/modules/aws/kube-worker/variables.tf index 8a6b777f..c6e54c2e 100644 --- a/modules/aws/kube-worker/variables.tf +++ b/modules/aws/kube-worker/variables.tf @@ -136,6 +136,7 @@ variable "instance_config" { description = "Desired worker nodes configuration." type = object({ count = number + max_count = number name = string image_id = string ec2_type = list(string) @@ -159,14 +160,16 @@ variable "instance_config" { variable "asg_warm_pool" { description = "Warm pool arguments of Auto Scaling group." type = object({ - enabled = bool - min_size = number - reuse_on_scale_in = bool + enabled = bool + min_size = number + reuse_on_scale_in = bool + max_group_prepared_capacity = number }) default = { - enabled = false - min_size = 1 - reuse_on_scale_in = false + enabled = false + min_size = 1 + reuse_on_scale_in = false + max_group_prepared_capacity = 1 } }