diff --git a/main.tf b/main.tf index aa19da8..8638bd1 100644 --- a/main.tf +++ b/main.tf @@ -114,6 +114,15 @@ resource "aws_eks_node_group" "eks_ng" { labels = length(var.labels) == 0 ? null : var.labels + node_repair_config { + enabled = var.enable_node_auto_repair + } + + update_config { + max_unavailable = var.max_unavailable_type == "count" ? var.max_unavailable : null + max_unavailable_percentage = var.max_unavailable_type == "percentage" ? var.max_unavailable : null + } + # Ensure that IAM Role permissions are created before and deleted after EKS Node Group handling. # Otherwise, EKS will not be able to properly delete EC2 Instances and Elastic Network Interfaces. depends_on = [ diff --git a/variables.tf b/variables.tf index 574ed83..054540e 100644 --- a/variables.tf +++ b/variables.tf @@ -65,14 +65,14 @@ variable "capacity_type" { variable "instance_types" { type = list(string) - default = ["t3.medium"] - description = "List of type of instances to be used as EKS worker nodes" + default = null + description = "List of type of instances to be used as EKS worker nodes. **Note:** Not required when using `launch_template` variable" } variable "disk_size" { type = number - default = 20 - description = "Size of each EBS volume attached to EKS worker node" + default = null + description = "Size of each EBS volume attached to EKS worker node. **Note:** Not required when using `launch_template` variable" } variable "labels" { @@ -83,8 +83,8 @@ variable "labels" { variable "ami_type" { type = string - default = "AL2_x86_64" - description = "Type of AMI to be used for EKS worker node. Supported values: AL2_x86_64, AL2_ARM_64, AL2_x86_64_GPU(AMI with GPU support)" + default = "AL2023_x86_64_STANDARD" + description = "Refer to [AWS doc](https://docs.aws.amazon.com/eks/latest/APIReference/API_Nodegroup.html#AmazonEKS-Type-Nodegroup-amiType) for supported AMI types" } variable "ami_release_version" { @@ -124,6 +124,29 @@ variable "force_update_version" { description = "Forcefully perform version update for worker nodes if pod disruption prevents node draining" } +variable "enable_node_auto_repair" { + type = bool + default = true + description = "Whether to enable node auto repair for the node group" +} + +variable "max_unavailable" { + type = number + default = 1 + description = "Maximum number/percentage of nodes that can be unavailable during the node group update" +} + +variable "max_unavailable_type" { + type = string + default = "count" + description = "Type of maximum unavailable nodes. **Valid values:** count or percentage" + + validation { + condition = var.max_unavailable_type == "count" || var.max_unavailable_type == "percentage" + error_message = "Invalid value for max_unavailable_type. Valid values: count or percentage" + } +} + variable "tags" { type = map(string) default = {}